From ac128eb78644955cc0d120defa155db15075858a Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Wed, 8 Aug 2018 20:39:38 +0200 Subject: [PATCH] Avoid crash when refreshing style sheet. For some reasons it helps to set and empty stylesheet upfront --- src/swiftcore/swiftcore.cpp | 7 ++++--- src/swiftlauncher/swiftlauncher.cpp | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/swiftcore/swiftcore.cpp b/src/swiftcore/swiftcore.cpp index 5ba3d7683..00a8d1574 100644 --- a/src/swiftcore/swiftcore.cpp +++ b/src/swiftcore/swiftcore.cpp @@ -78,13 +78,14 @@ CSwiftCore::~CSwiftCore() void CSwiftCore::initStyleSheet() { + if (!sGui || sGui->isShuttingDown()) { return; } const QString s = sGui->getStyleSheetUtility().styles( { CStyleSheetUtility::fileNameFonts(), CStyleSheetUtility::fileNameStandardWidget(), CStyleSheetUtility::fileNameSwiftCore() - } - ); + }); + this->setStyleSheet(""); // avoid crash, need to reset before this->setStyleSheet(s); } @@ -104,7 +105,7 @@ void CSwiftCore::showSettingsDialog() void CSwiftCore::showRawFsdMessageDialog() { - if(!m_rawFsdMessageDialog) + if (!m_rawFsdMessageDialog) { m_rawFsdMessageDialog.reset(new CRawFsdMessagesDialog(this)); } diff --git a/src/swiftlauncher/swiftlauncher.cpp b/src/swiftlauncher/swiftlauncher.cpp index 2e7b751c5..4783dfb28 100644 --- a/src/swiftlauncher/swiftlauncher.cpp +++ b/src/swiftlauncher/swiftlauncher.cpp @@ -180,6 +180,7 @@ void CSwiftLauncher::init() void CSwiftLauncher::initStyleSheet() { + if (!sGui || sGui->isShuttingDown()) { return; } const QString s = sGui->getStyleSheetUtility().styles( { CStyleSheetUtility::fileNameFonts(), @@ -187,6 +188,7 @@ void CSwiftLauncher::initStyleSheet() CStyleSheetUtility::fileNameSwiftLauncher() } ); + this->setStyleSheet(""); // clear, otherwise launcher crashing this->setStyleSheet(s); }