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