Add nullptr check for theme when initializing palette

Pick-to: 6.2 6.3 6.4
Change-Id: Iaac2c92f5f7e7fd5c25d6ecde058d4dc01c62aa1
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Doris Verria 2022-08-29 13:39:30 +02:00
parent 39cea8900b
commit 56e2e89955

View File

@ -344,8 +344,10 @@ QPlatformThemePrivate::~QPlatformThemePrivate()
Q_GUI_EXPORT QPalette qt_fusionPalette() Q_GUI_EXPORT QPalette qt_fusionPalette()
{ {
const bool darkAppearance = QGuiApplicationPrivate::platformTheme()->appearance() auto theme = QGuiApplicationPrivate::platformTheme();
== QPlatformTheme::Appearance::Dark; const bool darkAppearance = theme
? theme->appearance() == QPlatformTheme::Appearance::Dark
: false;
const QColor windowText = darkAppearance ? QColor(240, 240, 240) : Qt::black; const QColor windowText = darkAppearance ? QColor(240, 240, 240) : Qt::black;
const QColor backGround = darkAppearance ? QColor(50, 50, 50) : QColor(239, 239, 239); const QColor backGround = darkAppearance ? QColor(50, 50, 50) : QColor(239, 239, 239);
const QColor light = backGround.lighter(150); const QColor light = backGround.lighter(150);