From 69705d9e998557f0debf7412a0f5d98087af923a Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 19 May 2016 20:45:13 +0200 Subject: [PATCH] Detect and report version mismatches to the user between core & UI --- renderdocui/Interop/StaticExports.cs | 8 +++++ renderdocui/Windows/MainWindow.cs | 46 ++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/renderdocui/Interop/StaticExports.cs b/renderdocui/Interop/StaticExports.cs index 6843a8171..5304a5922 100644 --- a/renderdocui/Interop/StaticExports.cs +++ b/renderdocui/Interop/StaticExports.cs @@ -74,6 +74,9 @@ namespace renderdoc [DllImport("renderdoc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] private static extern IntPtr RENDERDOC_GetConfigSetting(IntPtr name); + [DllImport("renderdoc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr RENDERDOC_GetVersionString(); + [DllImport("renderdoc.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)] private static extern void RENDERDOC_SetConfigSetting(IntPtr name, IntPtr value); @@ -240,6 +243,11 @@ namespace renderdoc return CustomMarshal.PtrToStringUTF8(RENDERDOC_GetLogFile()); } + public static string GetVersionString() + { + return CustomMarshal.PtrToStringUTF8(RENDERDOC_GetVersionString()); + } + public static string GetConfigSetting(string name) { IntPtr name_mem = CustomMarshal.MakeUTF8String(name); diff --git a/renderdocui/Windows/MainWindow.cs b/renderdocui/Windows/MainWindow.cs index 6bb5edddd..9c7fc0ef4 100644 --- a/renderdocui/Windows/MainWindow.cs +++ b/renderdocui/Windows/MainWindow.cs @@ -588,6 +588,9 @@ namespace renderdocui.Windows Text += String.Format("{0}-beta - {1}", VersionString, GitCommitHash); else Text += String.Format("Unofficial release ({0} - {1})", VersionString, GitCommitHash); + + if (IsVersionMismatched()) + Text += " - !! VERSION MISMATCH DETECTED !!"; } private void SetTitle() @@ -1018,8 +1021,47 @@ namespace renderdocui.Windows private delegate void UpdateResultMethod(UpdateResult res); + private bool IsVersionMismatched() + { + return "v" + StaticExports.GetVersionString() != VersionString; + } + + private bool HandleMismatchedVersions() + { + if (IsVersionMismatched()) + { + if (!OfficialVersion && !BetaVersion) + { + MessageBox.Show("You are running an unofficial build with mismatched core and UI versions.\n" + + "Double check where you got your build from and do a sanity check!", + "Unofficial build - mismatched versions", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + else + { + DialogResult mb = MessageBox.Show("RenderDoc has detected mismatched versions between its internal module and UI.\n" + + "This is likely caused by a buggy update in the past which partially updated your install. Likely because a " + + "program was running with renderdoc while the update happened.\n" + + "You should reinstall RenderDoc immediately as this configuration is almost guaranteed to crash.\n\n" + + "Would you like to open the downloads page?", + "Mismatched versions", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); + + if (mb == DialogResult.Yes) + Process.Start("https://renderdoc.org/builds"); + + SetUpdateAvailable(); + } + return true; + } + + return false; + } + private void CheckUpdates(bool forceCheck = false, UpdateResultMethod callback = null) { + bool mismatch = HandleMismatchedVersions(); + if (mismatch) + return; + if (!forceCheck && !m_Core.Config.CheckUpdate_AllowChecks) { updateToolStripMenuItem.Text = "Update checks disabled"; @@ -1181,6 +1223,10 @@ namespace renderdocui.Windows private void updateToolStripMenuItem_Click(object sender, EventArgs e) { + bool mismatch = HandleMismatchedVersions(); + if (mismatch) + return; + SetUpdateAvailable(); UpdatePopup(); }