From 6259f4e7b473eb091700cb91e66c6fcc5b4f01c1 Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Sat, 11 Nov 2023 21:38:37 +0100 Subject: QGuiApplication: check return value of platformTheme::palette() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Under some circumstances (e.g. setDesktopSettingsAware(false) on windows) it may happen that the call to platformTheme::palette() returns a nullptr which is not checked before dereferencing the pointer. Therefore add a check for this to avoid a crash. Fixes: QTBUG-111527 Change-Id: I6443d5d1a9b813f499d8f65b4fee55b0b8299b16 Reviewed-by: Tor Arne Vestbø --- tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests') diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index 8542ce300f..2a2dbd0e48 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -47,6 +47,7 @@ private slots: void changeFocusWindow(); void keyboardModifiers(); void palette(); + void paletteNoCrash(); void font(); void modalWindow(); void quitOnLastWindowClosed(); @@ -552,6 +553,15 @@ void tst_QGuiApplication::palette() QCOMPARE(QGuiApplication::palette(), QPalette()); } +void tst_QGuiApplication::paletteNoCrash() +{ + QGuiApplication::setDesktopSettingsAware(false); + int argc = 1; + char *argv[] = { const_cast("tst_qguiapplication") }; + // this would crash on windows (QTBUG-111527) + QGuiApplication a(argc, argv); +} + void tst_QGuiApplication::font() { int argc = 1; -- cgit v1.2.3