Add nullptr check for theme when initializing palette

Change-Id: Iaac2c92f5f7e7fd5c25d6ecde058d4dc01c62aa1
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 56e2e899555c99d4013fdbef940a79de9dc542ea)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Doris Verria 2022-08-29 13:39:30 +02:00 committed by Qt Cherry-pick Bot
parent 9fd2cb559c
commit c17a16f468

View File

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