vcl/CustomTarget_qt5_moc.mk | 1 vcl/CustomTarget_qt6_moc.mk | 1 vcl/inc/qt5/QtAccessibleWidget.hxx | 11 ++ vcl/qt5/QtAccessibleWidget.cxx | 20 ++-- vcl/qt5/QtInstanceBuilder.cxx | 170 ++++++++++++++----------------------- 5 files changed, 91 insertions(+), 112 deletions(-)
New commits: commit 610c0285a6fd2c04b72d520eedc4eb2a6872e2f9 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu May 1 22:15:40 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri May 2 09:32:22 2025 +0200 qt: Move null check to start of QtAccessibleWidget::customFactory Check once at the beginning and return early in case of a null object instead of checking in different code paths. Also rename the param to `pObject` to match the naming convention for pointers. Change-Id: Ie1cf01e3292c7eb9ae463d956b9380bebc3b0f7c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184877 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/qt5/QtAccessibleWidget.cxx b/vcl/qt5/QtAccessibleWidget.cxx index d5febb36aaeb..1298c33068f0 100644 --- a/vcl/qt5/QtAccessibleWidget.cxx +++ b/vcl/qt5/QtAccessibleWidget.cxx @@ -800,11 +800,14 @@ QAccessibleInterface* QtAccessibleWidget::childAt(int x, int y) const awt::Point(aLocalCoords.x(), aLocalCoords.y())))); } -QAccessibleInterface* QtAccessibleWidget::customFactory(const QString& classname, QObject* object) +QAccessibleInterface* QtAccessibleWidget::customFactory(const QString& classname, QObject* pObject) { - if (classname == QLatin1String("QtWidget") && object && object->isWidgetType()) + if (!pObject) + return nullptr; + + if (classname == QLatin1String("QtWidget") && pObject->isWidgetType()) { - QtWidget* pWidget = static_cast<QtWidget*>(object); + QtWidget* pWidget = static_cast<QtWidget*>(pObject); vcl::Window* pWindow = pWidget->frame().GetWindow(); if (pWindow) @@ -812,16 +815,16 @@ QAccessibleInterface* QtAccessibleWidget::customFactory(const QString& classname css::uno::Reference<XAccessible> xAcc = pWindow->GetAccessible(); // insert into registry so the association between the XAccessible and the QtWidget // is remembered rather than creating a different QtXAccessible when a QObject is needed later - QtAccessibleRegistry::insert(xAcc, object); - return new QtAccessibleWidget(xAcc, object); + QtAccessibleRegistry::insert(xAcc, pObject); + return new QtAccessibleWidget(xAcc, pObject); } } - if (classname == QLatin1String("QtXAccessible") && object) + if (classname == QLatin1String("QtXAccessible")) { - QtXAccessible* pXAccessible = static_cast<QtXAccessible*>(object); + QtXAccessible* pXAccessible = static_cast<QtXAccessible*>(pObject); if (pXAccessible->m_xAccessible.is()) { - QtAccessibleWidget* pRet = new QtAccessibleWidget(pXAccessible->m_xAccessible, object); + QtAccessibleWidget* pRet = new QtAccessibleWidget(pXAccessible->m_xAccessible, pObject); // clear the reference in the QtXAccessible, no longer needed now that the QtAccessibleWidget holds one pXAccessible->m_xAccessible.clear(); return pRet; commit e5e4873576fa89f11e19ee568e3969fc3a4a03a7 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu May 1 21:59:51 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri May 2 09:32:16 2025 +0200 tdf#130857 qt: Let QtAccessibleWidget subclass QObject This will allow to pass it in a QVariant, which will be used to support custom accessible implementations for QtInstanceDrawingArea in QtInstanceBuilder::weld_drawing_area in an upcoming commit. At least the Qt 5 moc does not process Qt version checks like #if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) which would result in failures like In file included from /home/michi/development/git/libreoffice/vcl/qt5/QtAccessibleWidget.cxx:21: /home/michi/development/git/libreoffice/workdir/CustomTarget/vcl/qt5/QtAccessibleWidget.moc:91:29: error: unknown type name 'QAccessibleAttributesInterface'; did you mean 'QAccessibleActionInterface'? 91 | return static_cast< QAccessibleAttributesInterface*>(this); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | QAccessibleActionInterface /usr/include/x86_64-linux-gnu/qt5/QtGui/qaccessible.h:627:20: note: 'QAccessibleActionInterface' declared here 627 | class Q_GUI_EXPORT QAccessibleActionInterface | ^ In file included from /home/michi/development/git/libreoffice/vcl/qt5/QtAccessibleWidget.cxx:21: /home/michi/development/git/libreoffice/workdir/CustomTarget/vcl/qt5/QtAccessibleWidget.moc:97:29: error: unknown type name 'QAccessibleSelectionInterface'; did you mean 'QAccessibleActionInterface'? 97 | return static_cast< QAccessibleSelectionInterface*>(this); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | QAccessibleActionInterface /usr/include/x86_64-linux-gnu/qt5/QtGui/qaccessible.h:627:20: note: 'QAccessibleActionInterface' declared here 627 | class Q_GUI_EXPORT QAccessibleActionInterface | ^ 2 errors generated. Explicitly exclude the Qt >= 6.x specific code in the header from the moc run by making it conditional on #ifndef Q_MOC_RUN to make that work. Change-Id: I1ea3c37d0041dac89d632970d810ae951ff4afbb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184876 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/CustomTarget_qt5_moc.mk b/vcl/CustomTarget_qt5_moc.mk index 7e04d5756fbc..4a10cfd2b0f5 100644 --- a/vcl/CustomTarget_qt5_moc.mk +++ b/vcl/CustomTarget_qt5_moc.mk @@ -10,6 +10,7 @@ $(eval $(call gb_CustomTarget_CustomTarget,vcl/qt5)) $(call gb_CustomTarget_get_target,vcl/qt5) : \ + $(gb_CustomTarget_workdir)/vcl/qt5/QtAccessibleWidget.moc \ $(gb_CustomTarget_workdir)/vcl/qt5/QtClipboard.moc \ $(gb_CustomTarget_workdir)/vcl/qt5/QtDoubleSpinBox.moc \ $(gb_CustomTarget_workdir)/vcl/qt5/QtExpander.moc \ diff --git a/vcl/CustomTarget_qt6_moc.mk b/vcl/CustomTarget_qt6_moc.mk index 79b203ea70a1..9dee1cbb298e 100644 --- a/vcl/CustomTarget_qt6_moc.mk +++ b/vcl/CustomTarget_qt6_moc.mk @@ -10,6 +10,7 @@ $(eval $(call gb_CustomTarget_CustomTarget,vcl/qt6)) $(call gb_CustomTarget_get_target,vcl/qt6) : \ + $(gb_CustomTarget_workdir)/vcl/qt6/QtAccessibleWidget.moc \ $(gb_CustomTarget_workdir)/vcl/qt6/QtClipboard.moc \ $(gb_CustomTarget_workdir)/vcl/qt6/QtDoubleSpinBox.moc \ $(gb_CustomTarget_workdir)/vcl/qt6/QtExpander.moc \ diff --git a/vcl/inc/qt5/QtAccessibleWidget.hxx b/vcl/inc/qt5/QtAccessibleWidget.hxx index c02411ba2556..bc1ab406fe70 100644 --- a/vcl/inc/qt5/QtAccessibleWidget.hxx +++ b/vcl/inc/qt5/QtAccessibleWidget.hxx @@ -36,20 +36,27 @@ class XAccessibleTable; class QtFrame; class QtWidget; -class QtAccessibleWidget final : public QAccessibleInterface, +class QtAccessibleWidget final : public QObject, + public QAccessibleInterface, public QAccessibleActionInterface, +#ifndef Q_MOC_RUN #if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0) public QAccessibleAttributesInterface, +#endif #endif public QAccessibleTextInterface, public QAccessibleEditableTextInterface, +#ifndef Q_MOC_RUN #if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0) public QAccessibleSelectionInterface, +#endif #endif public QAccessibleTableCellInterface, public QAccessibleTableInterface, public QAccessibleValueInterface { + Q_OBJECT + public: QtAccessibleWidget(const css::uno::Reference<css::accessibility::XAccessible>& xAccessible, QObject* pObject); @@ -88,6 +95,7 @@ public: void doAction(const QString& actionName) override; QStringList keyBindingsForAction(const QString& actionName) const override; +#ifndef Q_MOC_RUN #if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0) // helper method for QAccessibleAttributesInterface QHash<QAccessible::Attribute, QVariant> attributes() const; @@ -95,6 +103,7 @@ public: // QAccessibleAttributesInterface QList<QAccessible::Attribute> attributeKeys() const override; QVariant attributeValue(QAccessible::Attribute key) const override; +#endif #endif // QAccessibleTextInterface diff --git a/vcl/qt5/QtAccessibleWidget.cxx b/vcl/qt5/QtAccessibleWidget.cxx index 03feffda5794..d5febb36aaeb 100644 --- a/vcl/qt5/QtAccessibleWidget.cxx +++ b/vcl/qt5/QtAccessibleWidget.cxx @@ -18,6 +18,7 @@ */ #include <QtAccessibleWidget.hxx> +#include <QtAccessibleWidget.moc> #include <QtGui/QAccessibleInterface> commit 960703ce7fe55af062bd33e6bc9f6f33bfd193e8 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Thu May 1 21:19:50 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Fri May 2 09:32:08 2025 +0200 tdf#130857 qt weld: Assert widgets exist, drop fallback In QtInstanceBuilder::weld_*, add asserts that the widgets for the passed ID exist and drop the fallback of returning an empty std::unique_ptr if they don't. Dialog implementations generally don't handle null return values anyway, and if these methods get called with an ID for which there isn't a corresponding widget, this needs to be investigated, so rather fail here early than due to a null dereference later. Change-Id: I6d018a4fe8b9ad19a01b7072281d5eb215ab8ef0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184875 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/vcl/qt5/QtInstanceBuilder.cxx b/vcl/qt5/QtInstanceBuilder.cxx index ec66f712ccce..4d251115a6c3 100644 --- a/vcl/qt5/QtInstanceBuilder.cxx +++ b/vcl/qt5/QtInstanceBuilder.cxx @@ -160,25 +160,22 @@ bool QtInstanceBuilder::IsUIFileSupported(const OUString& rUIFile) std::unique_ptr<weld::MessageDialog> QtInstanceBuilder::weld_message_dialog(const OUString& id) { QMessageBox* pMessageBox = m_xBuilder->get<QMessageBox>(id); - std::unique_ptr<weld::MessageDialog> xRet( - pMessageBox ? std::make_unique<QtInstanceMessageDialog>(pMessageBox) : nullptr); - return xRet; + assert(pMessageBox); + return std::make_unique<QtInstanceMessageDialog>(pMessageBox); } std::unique_ptr<weld::Dialog> QtInstanceBuilder::weld_dialog(const OUString& rId) { QDialog* pDialog = m_xBuilder->get<QDialog>(rId); - std::unique_ptr<weld::Dialog> xRet(pDialog ? std::make_unique<QtInstanceDialog>(pDialog) - : nullptr); - return xRet; + assert(pDialog); + return std::make_unique<QtInstanceDialog>(pDialog); } std::unique_ptr<weld::Assistant> QtInstanceBuilder::weld_assistant(const OUString& rId) { QWizard* pWizard = m_xBuilder->get<QWizard>(rId); - std::unique_ptr<weld::Assistant> xRet(pWizard ? std::make_unique<QtInstanceAssistant>(pWizard) - : nullptr); - return xRet; + assert(pWizard); + return std::make_unique<QtInstanceAssistant>(pWizard); } std::unique_ptr<weld::Window> QtInstanceBuilder::create_screenshot_window() @@ -190,17 +187,14 @@ std::unique_ptr<weld::Window> QtInstanceBuilder::create_screenshot_window() std::unique_ptr<weld::Widget> QtInstanceBuilder::weld_widget(const OUString& rId) { QWidget* pWidget = m_xBuilder->get<QWidget>(rId); - std::unique_ptr<weld::Widget> xRet(pWidget ? std::make_unique<QtInstanceWidget>(pWidget) - : nullptr); - return xRet; + assert(pWidget); + return std::make_unique<QtInstanceWidget>(pWidget); } std::unique_ptr<weld::Container> QtInstanceBuilder::weld_container(const OUString& rId) { QWidget* pWidget = m_xBuilder->get<QWidget>(rId); - if (!pWidget) - return nullptr; - + assert(pWidget); assert(pWidget->layout() && "no layout"); return std::make_unique<QtInstanceContainer>(pWidget); } @@ -208,9 +202,7 @@ std::unique_ptr<weld::Container> QtInstanceBuilder::weld_container(const OUStrin std::unique_ptr<weld::Box> QtInstanceBuilder::weld_box(const OUString& rId) { QWidget* pWidget = m_xBuilder->get<QWidget>(rId); - if (!pWidget) - return nullptr; - + assert(pWidget); assert(qobject_cast<QBoxLayout*>(pWidget->layout()) && "widget doesn't have a box layout"); return std::make_unique<QtInstanceBox>(pWidget); } @@ -218,9 +210,7 @@ std::unique_ptr<weld::Box> QtInstanceBuilder::weld_box(const OUString& rId) std::unique_ptr<weld::Grid> QtInstanceBuilder::weld_grid(const OUString& rId) { QWidget* pWidget = m_xBuilder->get<QWidget>(rId); - if (!pWidget) - return nullptr; - + assert(pWidget); assert(qobject_cast<QGridLayout*>(pWidget->layout()) && "no grid layout"); return std::make_unique<QtInstanceGrid>(pWidget); } @@ -234,42 +224,37 @@ std::unique_ptr<weld::Paned> QtInstanceBuilder::weld_paned(const OUString&) std::unique_ptr<weld::Frame> QtInstanceBuilder::weld_frame(const OUString& rId) { QGroupBox* pGroupBox = m_xBuilder->get<QGroupBox>(rId); - std::unique_ptr<weld::Frame> xRet(pGroupBox ? std::make_unique<QtInstanceFrame>(pGroupBox) - : nullptr); - return xRet; + assert(pGroupBox); + return std::make_unique<QtInstanceFrame>(pGroupBox); } std::unique_ptr<weld::ScrolledWindow> QtInstanceBuilder::weld_scrolled_window(const OUString& rId, bool) { QScrollArea* pScrollArea = m_xBuilder->get<QScrollArea>(rId); - std::unique_ptr<weld::ScrolledWindow> xRet( - pScrollArea ? std::make_unique<QtInstanceScrolledWindow>(pScrollArea) : nullptr); - return xRet; + assert(pScrollArea); + return std::make_unique<QtInstanceScrolledWindow>(pScrollArea); } std::unique_ptr<weld::Notebook> QtInstanceBuilder::weld_notebook(const OUString& rId) { QTabWidget* pTabWidget = m_xBuilder->get<QTabWidget>(rId); - std::unique_ptr<weld::Notebook> xRet( - pTabWidget ? std::make_unique<QtInstanceNotebook>(pTabWidget) : nullptr); - return xRet; + assert(pTabWidget); + return std::make_unique<QtInstanceNotebook>(pTabWidget); } std::unique_ptr<weld::Button> QtInstanceBuilder::weld_button(const OUString& rId) { QPushButton* pButton = m_xBuilder->get<QPushButton>(rId); - std::unique_ptr<weld::Button> xRet(pButton ? std::make_unique<QtInstanceButton>(pButton) - : nullptr); - return xRet; + assert(pButton); + return std::make_unique<QtInstanceButton>(pButton); } std::unique_ptr<weld::MenuButton> QtInstanceBuilder::weld_menu_button(const OUString& rId) { QToolButton* pButton = m_xBuilder->get<QToolButton>(rId); - std::unique_ptr<weld::MenuButton> xRet(pButton ? std::make_unique<QtInstanceMenuButton>(pButton) - : nullptr); - return xRet; + assert(pButton); + return std::make_unique<QtInstanceMenuButton>(pButton); } std::unique_ptr<weld::MenuToggleButton> QtInstanceBuilder::weld_menu_toggle_button(const OUString&) @@ -281,57 +266,50 @@ std::unique_ptr<weld::MenuToggleButton> QtInstanceBuilder::weld_menu_toggle_butt std::unique_ptr<weld::LinkButton> QtInstanceBuilder::weld_link_button(const OUString& rId) { QtHyperlinkLabel* pLabel = m_xBuilder->get<QtHyperlinkLabel>(rId); - std::unique_ptr<weld::LinkButton> xRet(pLabel ? std::make_unique<QtInstanceLinkButton>(pLabel) - : nullptr); - return xRet; + assert(pLabel); + return std::make_unique<QtInstanceLinkButton>(pLabel); } std::unique_ptr<weld::ToggleButton> QtInstanceBuilder::weld_toggle_button(const OUString& rId) { QAbstractButton* pButton = m_xBuilder->get<QAbstractButton>(rId); - std::unique_ptr<weld::ToggleButton> xRet( - pButton ? std::make_unique<QtInstanceToggleButton>(pButton) : nullptr); - return xRet; + assert(pButton); + return std::make_unique<QtInstanceToggleButton>(pButton); } std::unique_ptr<weld::RadioButton> QtInstanceBuilder::weld_radio_button(const OUString& rId) { QRadioButton* pRadioButton = m_xBuilder->get<QRadioButton>(rId); - std::unique_ptr<weld::RadioButton> xRet( - pRadioButton ? std::make_unique<QtInstanceRadioButton>(pRadioButton) : nullptr); - return xRet; + assert(pRadioButton); + return std::make_unique<QtInstanceRadioButton>(pRadioButton); } std::unique_ptr<weld::CheckButton> QtInstanceBuilder::weld_check_button(const OUString& rId) { QCheckBox* pCheckBox = m_xBuilder->get<QCheckBox>(rId); - std::unique_ptr<weld::CheckButton> xRet( - pCheckBox ? std::make_unique<QtInstanceCheckButton>(pCheckBox) : nullptr); - return xRet; + assert(pCheckBox); + return std::make_unique<QtInstanceCheckButton>(pCheckBox); } std::unique_ptr<weld::Scale> QtInstanceBuilder::weld_scale(const OUString& rId) { QSlider* pSlider = m_xBuilder->get<QSlider>(rId); - std::unique_ptr<weld::Scale> xRet(pSlider ? std::make_unique<QtInstanceScale>(pSlider) - : nullptr); - return xRet; + assert(pSlider); + return std::make_unique<QtInstanceScale>(pSlider); } std::unique_ptr<weld::ProgressBar> QtInstanceBuilder::weld_progress_bar(const OUString& rId) { QProgressBar* pProgressBar = m_xBuilder->get<QProgressBar>(rId); - std::unique_ptr<weld::ProgressBar> xRet( - pProgressBar ? std::make_unique<QtInstanceProgressBar>(pProgressBar) : nullptr); - return xRet; + assert(pProgressBar); + return std::make_unique<QtInstanceProgressBar>(pProgressBar); } std::unique_ptr<weld::LevelBar> QtInstanceBuilder::weld_level_bar(const OUString& rId) { QProgressBar* pProgressBar = m_xBuilder->get<QProgressBar>(rId); - std::unique_ptr<weld::LevelBar> xRet( - pProgressBar ? std::make_unique<QtInstanceLevelBar>(pProgressBar) : nullptr); - return xRet; + assert(pProgressBar); + return std::make_unique<QtInstanceLevelBar>(pProgressBar); } std::unique_ptr<weld::Spinner> QtInstanceBuilder::weld_spinner(const OUString&) @@ -343,8 +321,8 @@ std::unique_ptr<weld::Spinner> QtInstanceBuilder::weld_spinner(const OUString&) std::unique_ptr<weld::Image> QtInstanceBuilder::weld_image(const OUString& rId) { QLabel* pLabel = m_xBuilder->get<QLabel>(rId); - std::unique_ptr<weld::Image> xRet(pLabel ? std::make_unique<QtInstanceImage>(pLabel) : nullptr); - return xRet; + assert(pLabel); + return std::make_unique<QtInstanceImage>(pLabel); } std::unique_ptr<weld::Calendar> QtInstanceBuilder::weld_calendar(const OUString&) @@ -356,17 +334,15 @@ std::unique_ptr<weld::Calendar> QtInstanceBuilder::weld_calendar(const OUString& std::unique_ptr<weld::Entry> QtInstanceBuilder::weld_entry(const OUString& rId) { QLineEdit* pLineEdit = m_xBuilder->get<QLineEdit>(rId); - std::unique_ptr<weld::Entry> xRet(pLineEdit ? std::make_unique<QtInstanceEntry>(pLineEdit) - : nullptr); - return xRet; + assert(pLineEdit); + return std::make_unique<QtInstanceEntry>(pLineEdit); } std::unique_ptr<weld::SpinButton> QtInstanceBuilder::weld_spin_button(const OUString& rId) { QtDoubleSpinBox* pSpinBox = m_xBuilder->get<QtDoubleSpinBox>(rId); - std::unique_ptr<weld::SpinButton> xRet( - pSpinBox ? std::make_unique<QtInstanceSpinButton>(pSpinBox) : nullptr); - return xRet; + assert(pSpinBox); + return std::make_unique<QtInstanceSpinButton>(pSpinBox); } std::unique_ptr<weld::MetricSpinButton> @@ -379,17 +355,15 @@ std::unique_ptr<weld::FormattedSpinButton> QtInstanceBuilder::weld_formatted_spin_button(const OUString& rId) { QtDoubleSpinBox* pSpinBox = m_xBuilder->get<QtDoubleSpinBox>(rId); - std::unique_ptr<weld::FormattedSpinButton> xRet( - pSpinBox ? std::make_unique<QtInstanceFormattedSpinButton>(pSpinBox) : nullptr); - return xRet; + assert(pSpinBox); + return std::make_unique<QtInstanceFormattedSpinButton>(pSpinBox); } std::unique_ptr<weld::ComboBox> QtInstanceBuilder::weld_combo_box(const OUString& rId) { QComboBox* pComboBox = m_xBuilder->get<QComboBox>(rId); - std::unique_ptr<weld::ComboBox> xRet(pComboBox ? std::make_unique<QtInstanceComboBox>(pComboBox) - : nullptr); - return xRet; + assert(pComboBox); + return std::make_unique<QtInstanceComboBox>(pComboBox); } std::unique_ptr<weld::EntryTreeView> @@ -401,89 +375,79 @@ QtInstanceBuilder::weld_entry_tree_view(const OUString& rContainerId, const OUSt QTreeView* pTreeView = m_xBuilder->get<QTreeView>(rTreeViewId); assert(pWidget && pLineEdit && pTreeView); - std::unique_ptr<weld::EntryTreeView> xRet(std::make_unique<QtInstanceEntryTreeView>( - pWidget, pLineEdit, pTreeView, weld_entry(rEntryId), weld_tree_view(rTreeViewId))); - - return xRet; + return std::make_unique<QtInstanceEntryTreeView>( + pWidget, pLineEdit, pTreeView, weld_entry(rEntryId), weld_tree_view(rTreeViewId)); } std::unique_ptr<weld::TreeView> QtInstanceBuilder::weld_tree_view(const OUString& rId) { QTreeView* pTreeView = m_xBuilder->get<QTreeView>(rId); - std::unique_ptr<weld::TreeView> xRet(pTreeView ? std::make_unique<QtInstanceTreeView>(pTreeView) - : nullptr); - return xRet; + assert(pTreeView); + return std::make_unique<QtInstanceTreeView>(pTreeView); } std::unique_ptr<weld::IconView> QtInstanceBuilder::weld_icon_view(const OUString& rId) { QListView* pListView = m_xBuilder->get<QListView>(rId); - std::unique_ptr<weld::IconView> xRet(pListView ? std::make_unique<QtInstanceIconView>(pListView) - : nullptr); - return xRet; + assert(pListView); + return std::make_unique<QtInstanceIconView>(pListView); } std::unique_ptr<weld::Label> QtInstanceBuilder::weld_label(const OUString& rId) { QLabel* pLabel = m_xBuilder->get<QLabel>(rId); - std::unique_ptr<weld::Label> xRet(pLabel ? std::make_unique<QtInstanceLabel>(pLabel) : nullptr); - return xRet; + assert(pLabel); + return std::make_unique<QtInstanceLabel>(pLabel); } std::unique_ptr<weld::TextView> QtInstanceBuilder::weld_text_view(const OUString& rId) { QPlainTextEdit* pTextEdit = m_xBuilder->get<QPlainTextEdit>(rId); - std::unique_ptr<weld::TextView> xRet(pTextEdit ? std::make_unique<QtInstanceTextView>(pTextEdit) - : nullptr); - return xRet; + assert(pTextEdit); + return std::make_unique<QtInstanceTextView>(pTextEdit); } std::unique_ptr<weld::Expander> QtInstanceBuilder::weld_expander(const OUString& rId) { QtExpander* pExpander = m_xBuilder->get<QtExpander>(rId); - std::unique_ptr<weld::Expander> xRet(pExpander ? std::make_unique<QtInstanceExpander>(pExpander) - : nullptr); - return xRet; + assert(pExpander); + return std::make_unique<QtInstanceExpander>(pExpander); } std::unique_ptr<weld::DrawingArea> QtInstanceBuilder::weld_drawing_area(const OUString& rId, const a11yref&, FactoryFunction, void*) { QLabel* pLabel = m_xBuilder->get<QLabel>(rId); - std::unique_ptr<weld::DrawingArea> xRet(pLabel ? std::make_unique<QtInstanceDrawingArea>(pLabel) - : nullptr); - return xRet; + assert(pLabel); + return std::make_unique<QtInstanceDrawingArea>(pLabel); } std::unique_ptr<weld::Menu> QtInstanceBuilder::weld_menu(const OUString& rId) { QMenu* pMenu = m_xBuilder->get_menu(rId); - std::unique_ptr<weld::Menu> xRet(pMenu ? std::make_unique<QtInstanceMenu>(pMenu) : nullptr); - return xRet; + assert(pMenu); + return std::make_unique<QtInstanceMenu>(pMenu); } std::unique_ptr<weld::Popover> QtInstanceBuilder::weld_popover(const OUString& rId) { QWidget* pWidget = m_xBuilder->get<QWidget>(rId); - std::unique_ptr<weld::Popover> xRet(pWidget ? std::make_unique<QtInstancePopover>(pWidget) - : nullptr); - return xRet; + assert(pWidget); + return std::make_unique<QtInstancePopover>(pWidget); } std::unique_ptr<weld::Toolbar> QtInstanceBuilder::weld_toolbar(const OUString& rId) { QToolBar* pToolBar = m_xBuilder->get<QToolBar>(rId); - std::unique_ptr<weld::Toolbar> xRet(pToolBar ? std::make_unique<QtInstanceToolbar>(pToolBar) - : nullptr); - return xRet; + assert(pToolBar); + return std::make_unique<QtInstanceToolbar>(pToolBar); } std::unique_ptr<weld::Scrollbar> QtInstanceBuilder::weld_scrollbar(const OUString& rId) { QScrollBar* pScrollBar = m_xBuilder->get<QScrollBar>(rId); - std::unique_ptr<weld::Scrollbar> xRet( - pScrollBar ? std::make_unique<QtInstanceScrollbar>(pScrollBar) : nullptr); - return xRet; + assert(pScrollBar); + return std::make_unique<QtInstanceScrollbar>(pScrollBar); } std::unique_ptr<weld::SizeGroup> QtInstanceBuilder::create_size_group()