From 5d5a0842dc87645eab468389198750adc01b0618 Mon Sep 17 00:00:00 2001 From: Vitaly Fanaskov Date: Thu, 24 Oct 2019 14:24:42 +0200 Subject: QApplicationPrivate: Fix potential null pointer dereference The situation when qGuiApp is null is possible, for example, during static palette setup. This is also a bon ton to check pointers before dereferencing them. Task-number: QTBUG-71186 Change-Id: I8021cef073eedaa0e4c2eb621890e73e8126175c Reviewed-by: Friedemann Kleint Reviewed-by: Jesus Fernandez --- src/widgets/kernel/qapplication.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 3223781b63..3ded8c37e6 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1395,7 +1395,9 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* else *QApplicationPrivate::set_pal = palette; QCoreApplication::setAttribute(Qt::AA_SetPalette); - emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal); + + if (qGuiApp && QGuiApplicationPrivate::app_pal) + emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal); } } -- cgit v1.2.3