From 53f54ae882eba1bfac472dc63850ec0af9d1af90 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 1 May 2019 10:24:28 +0100 Subject: [PATCH] Clear cached updates if the version changes some other way. Closes #1368 --- qrenderdoc/Code/Interface/PersistantConfig.h | 7 +++++++ qrenderdoc/Windows/MainWindow.cpp | 11 +++++++++++ 2 files changed, 18 insertions(+) diff --git a/qrenderdoc/Code/Interface/PersistantConfig.h b/qrenderdoc/Code/Interface/PersistantConfig.h index 6593bc4b6..3a1c67eea 100644 --- a/qrenderdoc/Code/Interface/PersistantConfig.h +++ b/qrenderdoc/Code/Interface/PersistantConfig.h @@ -331,6 +331,8 @@ DECLARE_REFLECTION_STRUCT(BugReport); \ CONFIG_SETTING_VAL(public, bool, bool, CheckUpdate_UpdateAvailable, false) \ \ + CONFIG_SETTING_VAL(public, QString, rdcstr, CheckUpdate_CurrentVersion, "") \ + \ CONFIG_SETTING_VAL(public, QString, rdcstr, CheckUpdate_UpdateResponse, "") \ \ CONFIG_SETTING_VAL(public, QDateTime, rdcdatetime, CheckUpdate_LastUpdate, \ @@ -655,6 +657,11 @@ For more information about some of these settings that are user-facing see Defaults to ``False``. +.. data:: CheckUpdate_CurrentVersion + + The current version at the time of update checks. Used to determine if a cached pending update is + no longer valid because we got updated through some other method. + .. data:: CheckUpdate_UpdateResponse Contains the response from the update server from the last update check, with any release notes diff --git a/qrenderdoc/Windows/MainWindow.cpp b/qrenderdoc/Windows/MainWindow.cpp index 6ce0518c0..b8cd96d21 100644 --- a/qrenderdoc/Windows/MainWindow.cpp +++ b/qrenderdoc/Windows/MainWindow.cpp @@ -1214,6 +1214,15 @@ void MainWindow::CheckUpdates(bool forceCheck, UpdateResultMethod callback) } #if RENDERDOC_OFFICIAL_BUILD + + // if the current version isn't the one we expected, clear any cached update state + if(m_Ctx.Config().CheckUpdate_CurrentVersion != MAJOR_MINOR_VERSION_STRING) + { + m_Ctx.Config().CheckUpdate_UpdateAvailable = false; + m_Ctx.Config().CheckUpdate_UpdateResponse = ""; + m_Ctx.Config().CheckUpdate_CurrentVersion = MAJOR_MINOR_VERSION_STRING; + } + QDateTime today = QDateTime::currentDateTime(); // check by default every 2 days @@ -1290,6 +1299,7 @@ void MainWindow::CheckUpdates(bool forceCheck, UpdateResultMethod callback) { m_Ctx.Config().CheckUpdate_UpdateAvailable = false; m_Ctx.Config().CheckUpdate_UpdateResponse = ""; + m_Ctx.Config().CheckUpdate_CurrentVersion = lit(MAJOR_MINOR_VERSION_STRING); m_Ctx.Config().Save(); SetNoUpdate(); @@ -1301,6 +1311,7 @@ void MainWindow::CheckUpdates(bool forceCheck, UpdateResultMethod callback) m_Ctx.Config().CheckUpdate_UpdateAvailable = true; m_Ctx.Config().CheckUpdate_UpdateResponse = response; + m_Ctx.Config().CheckUpdate_CurrentVersion = lit(MAJOR_MINOR_VERSION_STRING); m_Ctx.Config().Save(); SetUpdateAvailable(); UpdatePopup();