From 230921a7f00d368551ecf5d6457765eae03e9325 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer Date: Mon, 21 Jan 2019 13:18:15 +0100 Subject: fix crash if no screens are available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: QTBUG-73166 Change-Id: I936672b7a09a540d21e6dcd371f5ffe1e5536b85 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qhighdpiscaling.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp index a455aa639d..22e46e0851 100644 --- a/src/gui/kernel/qhighdpiscaling.cpp +++ b/src/gui/kernel/qhighdpiscaling.cpp @@ -313,9 +313,12 @@ void QHighDpiScaling::updateHighDpiScaling() } m_active = m_globalScalingActive || m_screenFactorSet || m_pixelDensityScalingActive; - QPlatformScreen *primaryScreen = QGuiApplication::primaryScreen()->handle(); - qreal sf = screenSubfactor(primaryScreen); - QDpi primaryDpi = primaryScreen->logicalDpi(); + QScreen *primaryScreen = QGuiApplication::primaryScreen(); + if (!primaryScreen) + return; + QPlatformScreen *platformScreen = primaryScreen->handle(); + qreal sf = screenSubfactor(platformScreen); + QDpi primaryDpi = platformScreen->logicalDpi(); m_logicalDpi = QDpi(primaryDpi.first / sf, primaryDpi.second / sf); } -- cgit v1.2.3