From f8f3f0fbd468feaf14adcedbccbf6b434f2e2e49 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 15 Mar 2016 16:07:11 +0100 Subject: [PATCH] Correct qt_defaultDpi X/Y with just a QCoreApplication Makes the 96DPI attribute check avoid undefined behavior by using QCoreApplication::instance() directly, instead of calling through qApp, which performs an invalid cast to QGuiApplication. Change-Id: Ib86e7d2461b462a2d623f1364414f7d4d2293f22 Reviewed-by: Marc Mutz --- src/gui/text/qfont.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp index 2c5a0c74fc..fe68149346 100644 --- a/src/gui/text/qfont.cpp +++ b/src/gui/text/qfont.cpp @@ -131,7 +131,7 @@ extern bool qt_is_gui_used; Q_GUI_EXPORT int qt_defaultDpiX() { - if (qApp->testAttribute(Qt::AA_Use96Dpi)) + if (QCoreApplication::instance()->testAttribute(Qt::AA_Use96Dpi)) return 96; if (!qt_is_gui_used) @@ -146,7 +146,7 @@ Q_GUI_EXPORT int qt_defaultDpiX() Q_GUI_EXPORT int qt_defaultDpiY() { - if (qApp->testAttribute(Qt::AA_Use96Dpi)) + if (QCoreApplication::instance()->testAttribute(Qt::AA_Use96Dpi)) return 96; if (!qt_is_gui_used)