From 4b1d370f755578f60bd9c73ca98eeb8e71463caf Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 27 Dec 2019 11:48:26 +0100 Subject: Check platformNativeInterface pointer before dereferencing QApplication::platformNativeInterface() returns null if started with -platform offscreen. Fixes: QTBUG-80946 Change-Id: I3ad03ad27148c8576bd3fab0b136827bb8d171ae Reviewed-by: Christian Ehrlicher --- src/widgets/widgets/qmainwindow.cpp | 2 ++ src/widgets/widgets/qtoolbarlayout.cpp | 2 ++ 2 files changed, 4 insertions(+) (limited to 'src') diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index 16ed699137..e3dbe763e5 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -1364,6 +1364,8 @@ void QMainWindow::setUnifiedTitleAndToolBarOnMac(bool set) createWinId(); QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface(); + if (!nativeInterface) + return; // Not Cocoa platform plugin. QPlatformNativeInterface::NativeResourceForIntegrationFunction function = nativeInterface->nativeResourceFunctionForIntegration("setContentBorderEnabled"); if (!function) diff --git a/src/widgets/widgets/qtoolbarlayout.cpp b/src/widgets/widgets/qtoolbarlayout.cpp index 961a261e8f..92094a38fb 100644 --- a/src/widgets/widgets/qtoolbarlayout.cpp +++ b/src/widgets/widgets/qtoolbarlayout.cpp @@ -360,6 +360,8 @@ void QToolBarLayout::updateMacBorderMetrics() return; QPlatformNativeInterface *nativeInterface = QApplication::platformNativeInterface(); + if (!nativeInterface) + return; // Not Cocoa platform plugin. QPlatformNativeInterface::NativeResourceForIntegrationFunction function = nativeInterface->nativeResourceFunctionForIntegration("registerContentBorderArea"); if (!function) -- cgit v1.2.3