From 39ba5ed46aa96392148ee462de5fae4b9953b940 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 23 Jan 2025 08:34:32 +0200 Subject: [PATCH] Don't assume QDockWidgetGroupWindow has toolbars As part of 3d99f90b50ab22ef5ab4433c57f9ee584a0a7cae we added logic to look up the toolbar for a QMainWindowLayoutSeparatorHelper. In the case of QDockWidgetGroupWindow the logic was broken, as it was casting the layout's parentWidget(), the group window, to a QMainWindow, instead of using the group window's parent. However for QDockWidgetGroupWindow we shouldn't look for a toolbar at all, as QDockWidgetGroupWindow can't have a toolbar. Using the parent main window's toolbar is wrong, as mouse events for that window will not affect mouse events for the group window, so the bug in 3d99f90b50ab22ef5ab4433c57f9ee584a0a7cae is not triggered. Fixes: QTBUG-132952 Pick-to: 6.5 Change-Id: Ic7845254e05bc358a39f79ec7622029d90173b45 Reviewed-by: Volker Hilsheimer Reviewed-by: Axel Spoerl (cherry picked from commit 81ed068a510421e6204193ec37448a628324543d) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit ccbf28a56c071898e4cfc23cd353e5061213ca54) --- src/widgets/widgets/qmainwindowlayout.cpp | 3 +-- src/widgets/widgets/qmainwindowlayout_p.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index ee854615e90..1267266e4d6 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -277,8 +277,7 @@ public: #if QT_CONFIG(toolbar) QToolBarAreaLayout *toolBarAreaLayout() { - auto *mainWindow = static_cast(parentWidget()); - return qt_mainwindow_layout(mainWindow)->toolBarAreaLayout(); + return nullptr; // QDockWidgetGroupWindow doesn't have toolbars } #endif diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h index f4211046e1c..54fc6fea0c3 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -289,7 +289,7 @@ QList QMainWindowLayoutSeparatorHelper::findSeparator(const QPoint Layout *layout = const_cast(this->layout()); #if QT_CONFIG(toolbar) QToolBarAreaLayout *toolBarAreaLayout = layout->toolBarAreaLayout(); - if (!toolBarAreaLayout->isEmpty()) { + if (toolBarAreaLayout && !toolBarAreaLayout->isEmpty()) { // We might have a toolbar that is currently expanded, covering // parts of the dock area, in which case we don't want the dock // area layout to treat mouse events for the expanded toolbar as