vcl/qt: don't re-add widgets to a layout they're already part of

If the parent widget already has a layout, then creating a new
widget and passing the parent in the widget's constructor will
add the widget to the layout. If the widget is later added
to the layout again, it will be removed from the layout and
re-added. This is unecessary.

Change-Id: I64e27080a1546e126dfc8ee57d3e1e558574d6a3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/206477
Reviewed-by: Dan Williams <dcbw@libreoffice.org>
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
This commit is contained in:
Dan Williams
2026-09-04 20:41:50 +02:00
parent 62ace1c1d6
commit 86e934c603
+2 -2
View File
@@ -504,8 +504,8 @@ QObject* QtBuilder::insertObject(QObject* pParent, const OUString& rClass, std::
pParentLayout = new QVBoxLayout(pParentWidget);
}
// add widget to parent layout
if (pParentLayout)
// add widget to parent layout if it wasn't added by Qt already
if (pParentLayout && (pParentLayout->indexOf(pWidget) < 0))
pParentLayout->addWidget(pWidget);
setWidgetAlignment(*pWidget, rProps);