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 <Friedemann.Kleint@qt.io>
Reviewed-by: Jesus Fernandez <jsfdez@gmail.com>
This commit is contained in:
Vitaly Fanaskov 2019-10-24 14:24:42 +02:00
parent 7a605edc22
commit 5d5a0842dc

View File

@ -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);
}
}