From 7e0f0e470ea7e93fcf8f3fb750108682574aee7b Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 9 Feb 2021 13:42:12 +0200 Subject: [PATCH] StudioWelcome: Pause splash close timer while restart dialog is active Fixes: QDS-3332 Change-Id: I16e6646202c97453b76a5e3a848b733ad460514c Reviewed-by: Mahmoud Badri --- .../studiowelcome/studiowelcomeplugin.cpp | 29 +++++++++++++++++-- .../studiowelcome/studiowelcomeplugin.h | 5 ++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/plugins/studiowelcome/studiowelcomeplugin.cpp b/src/plugins/studiowelcome/studiowelcomeplugin.cpp index e80075acaeb..5cb362b0998 100644 --- a/src/plugins/studiowelcome/studiowelcomeplugin.cpp +++ b/src/plugins/studiowelcome/studiowelcomeplugin.cpp @@ -64,6 +64,7 @@ namespace Internal { const char DO_NOT_SHOW_SPLASHSCREEN_AGAIN_KEY[] = "StudioSplashScreen"; QPointer s_view = nullptr; +static StudioWelcomePlugin *s_pluginInstance = nullptr; static bool isUsageStatistic(const ExtensionSystem::PluginSpec *spec) { @@ -115,10 +116,14 @@ public: plugin->setEnabledBySettings(b); ExtensionSystem::PluginManager::writeSettings(); + // pause remove splash timer while dialog is open otherwise splash crashes upon removal + s_pluginInstance->pauseRemoveSplashTimer(); + const QString restartText = tr("The change will take effect after restart."); Core::RestartDialog restartDialog(Core::ICore::dialogParent(), restartText); restartDialog.exec(); + s_pluginInstance->resumeRemoveSplashTimer(); setupModel(); } @@ -270,10 +275,14 @@ void StudioWelcomePlugin::showSystemSettings() Core::ICore::infoBar()->globallySuppressInfo("WarnCrashReporting"); // pause remove splash timer while settings dialog is open otherwise splash crashes upon removal - int splashAutoCloseRemainingTime = m_removeSplashTimer.remainingTime(); // milliseconds - m_removeSplashTimer.stop(); + pauseRemoveSplashTimer(); Core::ICore::showOptionsDialog(Core::Constants::SETTINGS_ID_SYSTEM); - m_removeSplashTimer.start(splashAutoCloseRemainingTime); + resumeRemoveSplashTimer(); +} + +StudioWelcomePlugin::StudioWelcomePlugin() +{ + s_pluginInstance = this; } StudioWelcomePlugin::~StudioWelcomePlugin() @@ -359,6 +368,20 @@ bool StudioWelcomePlugin::delayedInitialize() return false; } +void StudioWelcomePlugin::pauseRemoveSplashTimer() +{ + if (m_removeSplashTimer.isActive()) { + m_removeSplashRemainingTime = m_removeSplashTimer.remainingTime(); // milliseconds + m_removeSplashTimer.stop(); + } +} + +void StudioWelcomePlugin::resumeRemoveSplashTimer() +{ + if (!m_removeSplashTimer.isActive()) + m_removeSplashTimer.start(m_removeSplashRemainingTime); +} + WelcomeMode::WelcomeMode() { setDisplayName(tr("Studio")); diff --git a/src/plugins/studiowelcome/studiowelcomeplugin.h b/src/plugins/studiowelcome/studiowelcomeplugin.h index ddc86807b9b..a7012d31e59 100644 --- a/src/plugins/studiowelcome/studiowelcomeplugin.h +++ b/src/plugins/studiowelcome/studiowelcomeplugin.h @@ -42,15 +42,20 @@ public slots: void showSystemSettings(); public: + StudioWelcomePlugin(); ~StudioWelcomePlugin() final; bool initialize(const QStringList &arguments, QString *errorString) override; void extensionsInitialized() override; bool delayedInitialize() override; + void pauseRemoveSplashTimer(); + void resumeRemoveSplashTimer(); + private: class WelcomeMode *m_welcomeMode = nullptr; QTimer m_removeSplashTimer; + int m_removeSplashRemainingTime = 0; }; } // namespace Internal