tdf#130857 qt weld: Drop assert for layout in QtInstanceContainer ctor
QtInstanceContainer has a virtual QtInstanceContainer::getLayout
method that is responsible for providing a QLayout when needed.
The base class implementation just returns the widget's layout,
but subclasses could be doing something else. Therefore, don't
already assert that the widget has a layout in the ctor.
If QtInstanceContainer::getLayout is called, that one
already has the same assert. (Add a message to that assert.)
This way, the check will only be performed once a layout
is actually needed.
The main motivation for this change is that QColorDialog
used in QtInstanceColorChooserDialog isn't guaranteed to
have a layout when a platform-native one is used, which
is e.g. the case on current KDE Plasma by default,
unless deactivated, which could be done like this:
--- a/vcl/qt5/QtInstance.cxx
+++ b/vcl/qt5/QtInstance.cxx
@@ -985,6 +985,7 @@ QtInstance::CreateColorChooserDialog(weld::Window* pParent, vcl::ColorPickerMode
std::unique_ptr<weld::ColorChooserDialog> pColorChooserDialog;
RunInMainThread([&] {
QColorDialog* pDialog = new QColorDialog(GetQWidget(pParent));
+ pDialog->setOption(QColorDialog::DontUseNativeDialog);
pColorChooserDialog = std::make_unique<QtInstanceColorChooserDialog>(pDialog);
});
Without this change (and without deactivating the native dialog),
opening e.g. the font color chooser in the Writer formatting
toolbar and then pressing the "Custom color..." button would
otherwise trigger the assert.
(QtInstanceColorChooserDialog also doesn't override
QtInstanceContainer::getLayout, so if any of the
weld::Container method implementations actually requiring
a layout were ever called the assert would still be triggered,
but that is not the case. Should that ever become relevant
in the future, disabling the native dialog could be one
potential way forward.)
Change-Id: I6d34e46d564af7a7da56cba5413872e13ba51a9e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/211420
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
QtInstanceContainer::QtInstanceContainer(QWidget* pWidget)
|
||||
: QtInstanceWidget(pWidget)
|
||||
{
|
||||
assert(pWidget->layout() && "no layout to use for container");
|
||||
}
|
||||
|
||||
void QtInstanceContainer::move(weld::Widget* pWidget, weld::Container* pNewParent)
|
||||
@@ -92,7 +91,7 @@ void QtInstanceContainer::connect_container_focus_changed(const Link<Container&,
|
||||
QLayout& QtInstanceContainer::getLayout() const
|
||||
{
|
||||
QLayout* pLayout = getQWidget()->layout();
|
||||
assert(pLayout);
|
||||
assert(pLayout && "Widget doesn't have a layout");
|
||||
return *pLayout;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user