summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2023-11-11 21:38:37 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2023-11-14 20:24:58 +0100
commit6259f4e7b473eb091700cb91e66c6fcc5b4f01c1 (patch)
tree1223c87b3869af327088faafa4a54dcd946a8c47 /tests/auto/gui
parent6e8563fb2d59e8715aa2a34bb75bb2712de194cb (diff)
QGuiApplication: check return value of platformTheme::palette()
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ø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'tests/auto/gui')
-rw-r--r--tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp10
1 files changed, 10 insertions, 0 deletions
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<char*>("tst_qguiapplication") };
+ // this would crash on windows (QTBUG-111527)
+ QGuiApplication a(argc, argv);
+}
+
void tst_QGuiApplication::font()
{
int argc = 1;