diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2024-12-18 20:46:32 +0100 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2024-12-19 08:28:27 +0100 |
commit | 111edc82743369fd1557784566a46c8e03dc4bbd (patch) | |
tree | 448b9b907d2165fe01d9a3454fd3212ee1d3cabd /vcl/inc | |
parent | fb3f9d72d102dcfde93d32660ebb59a4bb75a5b3 (diff) |
tdf#130857 qt weld: Map ID to to parent QWidget for layouts
QBoxLayout (created for "GtkBox" in .ui files) and QGridLayout
(created for "GtkGrid" in .ui files) are QLayout subclasses,
not QWidgets.
So far, QtBuilder::m_aChildren was containing QObjects
that could be either QWidgets or QLayouts.
QtInstanceBuilder::weld_container and QtInstanceBuilder::weld_grid
were retrieving the corresponding QLayout using QtBuilder::get,
all other QtInstanceBuilder::weld_* methods the corresponding
QWidget.
However, for a "GtkBox" or "GtkGrid", it's not only possible
to call QtInstanceBuilder::weld_container or
QtInstanceBuilder::weld_grid, but it's also possible
to just get a pointer to the weld::Widget subclass by calling
QtInstanceBuilder::weld_widget with the ID of the grid/box.
So far, this would have resulted in QtInstanceBuilder::weld_widget
calling QtBuilder::get<QWidget>, in which case the latter
would incorrectly `static_cast` the QLayout to a QWidget.
Since
commit bf42162fc50d0c6f8e567d8765f8b14b96d7cc50
Author: Michael Weghorn <m.weghorn@posteo.de>
Date: Mon Nov 4 19:06:15 2024 +0100
tdf#130857 qt weld: Add extra QWidget parents for layouts
, extra parent widgets for the layouts (except for the top-level
ones in dialogs) are created. Insert these into QtBuilder::m_aChildren
instead and retrieve them by the ID, which allows to uniformly use
QWidget. Adjust QtInstanceBuilder::weld_{container,grid} accordingly.
(Special handling for top-level layouts in containers can
still be added as needed later.)
This fixes an assert seen in a WIP branch where suport
for the FontFeaturesDialog (open context menu for paragraph in Writer,
select "Character" -> "Character" to open the "Character" dialog,
in the "Font" tab, click on the "Features" button) is declared.
Backtrace, where FontFeaturesDialog::m_xContainer is a weld::Widget
referring to the "fontentry" GtkGrid in
cui/uiconfig/ui/fontfragment.ui:
1 __pthread_kill_implementation pthread_kill.c 44 0x7ffff789dc8c
2 __pthread_kill_internal pthread_kill.c 78 0x7ffff789dcef
3 __GI_raise raise.c 26 0x7ffff7849c42
4 __GI_abort abort.c 79 0x7ffff78324f0
5 __assert_fail_base assert.c 94 0x7ffff7832418
6 __assert_fail assert.c 103 0x7ffff7842552
7 QtInstanceGrid::set_child_left_attach(weld::Widget&, int)::$_0::operator()() const QtInstanceGrid.cxx 25 0x7fffe438b5e1
8 std::__invoke_impl<void, QtInstanceGrid::set_child_left_attach(weld::Widget&, int)::$_0&>(std::__invoke_other, QtInstanceGrid::set_child_left_attach(weld::Widget&, int)::$_0&) invoke.h 61 0x7fffe438b4f5
9 std::__invoke_r<void, QtInstanceGrid::set_child_left_attach(weld::Widget&, int)::$_0&>(QtInstanceGrid::set_child_left_attach(weld::Widget&, int)::$_0&) invoke.h 111 0x7fffe438b4b5
10 std::_Function_handler<void(), QtInstanceGrid::set_child_left_attach(weld::Widget&, int)::$_0>::_M_invoke std_function.h 290 0x7fffe438b39d
11 std::function<void()>::operator() std_function.h 591 0x7fffe4345aee
12 QtInstance::RunInMainThread QtInstance.cxx 226 0x7fffe433d67a
13 QtInstanceGrid::set_child_left_attach QtInstanceGrid.cxx 23 0x7fffe438aa63
14 cui::FontFeaturesDialog::fillGrid FontFeaturesDialog.cxx 142 0x7fff6db25fb1
15 cui::FontFeaturesDialog::initialize FontFeaturesDialog.cxx 73 0x7fff6db2541d
16 cui::FontFeaturesDialog::FontFeaturesDialog FontFeaturesDialog.cxx 35 0x7fff6db24f61
17 SvxCharNamePage::FontFeatureButtonClicked chardlg.cxx 1154 0x7fff6de651d1
18 SvxCharNamePage::LinkStubFontFeatureButtonClicked chardlg.cxx 1131 0x7fff6de5fa7d
19 Link<weld::Button&, void>::Call link.hxx 111 0x7fffeec54551
20 weld::Button::signal_clicked weld.hxx 1558 0x7fffeec3078c
21 SalInstanceButton::ClickHdl salvtables.cxx 2955 0x7fffeec018ee
22 SalInstanceButton::LinkStubClickHdl salvtables.cxx 2943 0x7fffeec00e2d
23 Link<Button *, void>::Call link.hxx 111 0x7fffee508da1
24 Button::Click()::$_0::operator()() const button.cxx 130 0x7fffee5005f2
...
Change-Id: I7901b9085f887acef7b5505eef0baa792816cd0d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178752
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'vcl/inc')
-rw-r--r-- | vcl/inc/qt5/QtBuilder.hxx | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/vcl/inc/qt5/QtBuilder.hxx b/vcl/inc/qt5/QtBuilder.hxx index aaed05ef434e..db4505902380 100644 --- a/vcl/inc/qt5/QtBuilder.hxx +++ b/vcl/inc/qt5/QtBuilder.hxx @@ -27,14 +27,14 @@ class QtBuilder : public WidgetBuilder<QObject, QObject*, QMenu, QMenu*> { private: - QObject* get_by_name(std::u16string_view sID); + QWidget* get_by_name(std::u16string_view sID); struct WinAndId { OUString m_sID; - QObject* m_pWindow; - WinAndId(OUString sId, QObject* pWindow) + QWidget* m_pWidget; + WinAndId(OUString sId, QWidget* pWidget) : m_sID(std::move(sId)) - , m_pWindow(pWindow) + , m_pWidget(pWidget) { } }; |