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 <volker.hilsheimer@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
(cherry picked from commit 81ed068a510421e6204193ec37448a628324543d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2025-01-23 08:34:32 +02:00 committed by Qt Cherry-pick Bot
parent 2d819c7027
commit ccbf28a56c
2 changed files with 2 additions and 3 deletions

View File

@ -276,8 +276,7 @@ public:
#if QT_CONFIG(toolbar)
QToolBarAreaLayout *toolBarAreaLayout()
{
auto *mainWindow = static_cast<QMainWindow*>(parentWidget());
return qt_mainwindow_layout(mainWindow)->toolBarAreaLayout();
return nullptr; // QDockWidgetGroupWindow doesn't have toolbars
}
#endif

View File

@ -289,7 +289,7 @@ QList<int> QMainWindowLayoutSeparatorHelper<Layout>::findSeparator(const QPoint
Layout *layout = const_cast<Layout*>(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