diff options
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 6 | ||||
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 8 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index e534ba377f..bab525f809 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -4102,8 +4102,7 @@ void QGuiApplicationPrivate::notifyThemeChanged() clearPalette(); initPalette(); emit qGuiApp->paletteChanged(*app_pal); - if (is_app_running && !is_app_closing) - sendApplicationPaletteChange(); + sendApplicationPaletteChange(); } if (!(applicationResourceFlags & ApplicationFontExplicitlySet)) { const auto locker = qt_scoped_lock(applicationFontMutex); @@ -4118,6 +4117,9 @@ void QGuiApplicationPrivate::sendApplicationPaletteChange(bool toAllWidgets, con Q_UNUSED(toAllWidgets) Q_UNUSED(className) + if (!is_app_running || is_app_closing) + return; + QEvent event(QEvent::ApplicationPaletteChange); QGuiApplication::sendEvent(QGuiApplication::instance(), &event); } diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 5a21a3a15c..6120e0e164 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1390,10 +1390,9 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* hash->insert(className, pal); } - if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) { - // Send ApplicationPaletteChange to qApp itself, and to the widgets. + + if (qApp) qApp->d_func()->sendApplicationPaletteChange(all, className); - } if (!className && (!QApplicationPrivate::sys_pal || !palette.isCopyOf(*QApplicationPrivate::sys_pal))) { QCoreApplication::setAttribute(Qt::AA_SetPalette); @@ -4431,6 +4430,9 @@ void QApplicationPrivate::notifyThemeChanged() void QApplicationPrivate::sendApplicationPaletteChange(bool toAllWidgets, const char *className) { + if (!is_app_running || is_app_closing) + return; + QGuiApplicationPrivate::sendApplicationPaletteChange(); QEvent event(QEvent::ApplicationPaletteChange); |