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