Clarify call to initializeWidgetFontHash in QApplication::setStyle

The call was added in c49c96fbb1, "Reinitialize system palette
when setting a new style", but adding it along with the palette code
seems like a mistake. The potentially dirty widget font hash needs
to be reset for all style changes.

Change-Id: I411f56bb833819213c5485d7585fc5e3e9bd8983
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Tor Arne Vestbø 2019-06-21 13:40:50 +02:00
parent f733c1c6e7
commit 14071b5a8e

View File

@ -1133,12 +1133,18 @@ void QApplication::setStyle(QStyle *style)
} else if (QApplicationPrivate::sys_pal) {
clearSystemPalette();
initSystemPalette();
QApplicationPrivate::initializeWidgetFontHash();
} else if (!QApplicationPrivate::sys_pal) {
// Initialize the sys_pal if it hasn't happened yet...
QApplicationPrivate::setSystemPalette(QApplicationPrivate::app_style->standardPalette());
}
// The default widget font hash is based on the platform theme,
// not the style, but the widget fonts could in theory have been
// affected by polish of the previous style, without a proper
// cleanup in unpolish, so reset it now before polishing the
// new style.
QApplicationPrivate::initializeWidgetFontHash();
// initialize the application with the new style
QApplicationPrivate::app_style->polish(qApp);