From ccbf28a56c071898e4cfc23cd353e5061213ca54 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.8 6.5 Change-Id: Ic7845254e05bc358a39f79ec7622029d90173b45 Reviewed-by: Volker Hilsheimer Reviewed-by: Axel Spoerl (cherry picked from commit 81ed068a510421e6204193ec37448a628324543d) Reviewed-by: Qt Cherry-pick Bot --- 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 2cc7f585d09..a83587a78a0 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -276,8 +276,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 e2770fd58d5..7e22788ec49 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