From: alex-z Date: Wed, 30 Mar 2022 15:07:49 +0000 (+0300) Subject: Darkmode. Fix crash on exit. X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~17^2~81^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b34f639fff1d65d7379633994d7bb2c299c38b7a;p=nextcloud-desktop.git Darkmode. Fix crash on exit. Signed-off-by: alex-z --- diff --git a/src/libsync/theme.cpp b/src/libsync/theme.cpp index 34bea7287..eb2268ca2 100644 --- a/src/libsync/theme.cpp +++ b/src/libsync/theme.cpp @@ -904,12 +904,11 @@ QColor Theme::errorBoxBorderColor() const void Theme::connectToPaletteSignal() { - if(!_guiAppInstance) { - const auto ptr = qobject_cast(QGuiApplication::instance()); - if(ptr) { - _guiAppInstance.reset(ptr); - connect(_guiAppInstance.data(), &QGuiApplication::paletteChanged, this, &Theme::systemPaletteChanged); - connect(_guiAppInstance.data(), &QGuiApplication::paletteChanged, this, &Theme::darkModeChanged); + if (!_paletteSignalsConnected) { + if (const auto ptr = qobject_cast(QGuiApplication::instance())) { + connect(ptr, &QGuiApplication::paletteChanged, this, &Theme::systemPaletteChanged); + connect(ptr, &QGuiApplication::paletteChanged, this, &Theme::darkModeChanged); + _paletteSignalsConnected = true; } } } diff --git a/src/libsync/theme.h b/src/libsync/theme.h index df9303b23..180efbec2 100644 --- a/src/libsync/theme.h +++ b/src/libsync/theme.h @@ -627,7 +627,7 @@ private: static Theme *_instance; bool _mono = false; - QScopedPointer _guiAppInstance; + bool _paletteSignalsConnected = false; #ifndef TOKEN_AUTH_ONLY mutable QHash _iconCache;