From df69364469c6816dab0f364f0687946a8d566679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 25 Jun 2019 16:53:37 +0200 Subject: Remove QApplicationPrivate::set_pal Its purpose was to track the default palette set by the programmer, but after 8fb881900c this is tracked by the Qt::AA_SetPalette attribute. The palette itself is always reflected 1:1 in the palette tracked by QGuiApplicationPrivate::app_pal. Change-Id: If3e84c8b3ae6070b6c50be7a33adb38799b3f3a5 Reviewed-by: Timur Pocheptsov --- src/widgets/kernel/qapplication.cpp | 18 ++++++------------ src/widgets/kernel/qapplication_p.h | 1 - 2 files changed, 6 insertions(+), 13 deletions(-) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 2a1a21596c..5a21a3a15c 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -382,7 +382,6 @@ QString QApplicationPrivate::styleSheet; // default application styles QPointer QApplicationPrivate::leaveAfterRelease = 0; QPalette *QApplicationPrivate::sys_pal = 0; // default system palette -QPalette *QApplicationPrivate::set_pal = 0; // default palette set by programmer QFont *QApplicationPrivate::sys_font = 0; // default system font QFont *QApplicationPrivate::set_font = 0; // default font set by programmer @@ -803,8 +802,6 @@ QApplication::~QApplication() delete QApplicationPrivate::app_pal; QApplicationPrivate::app_pal = 0; clearSystemPalette(); - delete QApplicationPrivate::set_pal; - QApplicationPrivate::set_pal = 0; app_palettes()->clear(); delete QApplicationPrivate::sys_font; @@ -1057,8 +1054,8 @@ QStyle *QApplication::style() initSystemPalette(); - if (auto *explicitlySetPalette = QApplicationPrivate::set_pal) - defaultStyle->polish(*explicitlySetPalette); + if (testAttribute(Qt::AA_SetPalette)) + defaultStyle->polish(*QGuiApplicationPrivate::app_pal); #ifndef QT_NO_STYLE_STYLESHEET if (!QApplicationPrivate::styleSheet.isEmpty()) { @@ -1132,8 +1129,8 @@ void QApplication::setStyle(QStyle *style) // take care of possible palette requirements of certain gui // styles. Do it before polishing the application since the style // might call QApplication::setPalette() itself - if (auto *explicitlySetPalette = QApplicationPrivate::set_pal) { - QApplicationPrivate::app_style->polish(*explicitlySetPalette); + if (testAttribute(Qt::AA_SetPalette)) { + QApplicationPrivate::app_style->polish(*QGuiApplicationPrivate::app_pal); } else { if (QApplicationPrivate::sys_pal) clearSystemPalette(); @@ -1397,11 +1394,8 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* // Send ApplicationPaletteChange to qApp itself, and to the widgets. qApp->d_func()->sendApplicationPaletteChange(all, className); } + if (!className && (!QApplicationPrivate::sys_pal || !palette.isCopyOf(*QApplicationPrivate::sys_pal))) { - if (!QApplicationPrivate::set_pal) - QApplicationPrivate::set_pal = new QPalette(palette); - else - *QApplicationPrivate::set_pal = palette; QCoreApplication::setAttribute(Qt::AA_SetPalette); emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal); } @@ -1444,7 +1438,7 @@ void QApplicationPrivate::setSystemPalette(const QPalette &pal) else *sys_pal = pal; - if (!QApplicationPrivate::set_pal) + if (!testAttribute(Qt::AA_SetPalette)) QApplication::setPalette(*sys_pal); } diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index 3167bd423f..79d06ed98c 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -162,7 +162,6 @@ public: static QWidgetList *popupWidgets; static QStyle *app_style; static QPalette *sys_pal; - static QPalette *set_pal; protected: void notifyThemeChanged() override; -- cgit v1.2.3