From 16561cd1175443cb95fc52580f1ef8b92b811ea1 Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 19 May 2016 20:29:38 +0200 Subject: [PATCH] Before updating, check to see if any live programs are running. * Doing this early and via the remote access lets us give a friendly error message and direct the user to which program is currently using renderdoc. --- renderdocui/Windows/Dialogs/UpdateDialog.cs | 49 ++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/renderdocui/Windows/Dialogs/UpdateDialog.cs b/renderdocui/Windows/Dialogs/UpdateDialog.cs index 5f0255bae..1cff57240 100644 --- a/renderdocui/Windows/Dialogs/UpdateDialog.cs +++ b/renderdocui/Windows/Dialogs/UpdateDialog.cs @@ -62,13 +62,60 @@ namespace renderdocui.Windows.Dialogs if (result == DialogResult.Yes) { - progressText.Text = "Connecting"; + progressText.Text = "Preparing"; close.Enabled = false; doupdate.Enabled = false; var updateThread = Helpers.NewThread(new ThreadStart(() => { + var idents = renderdoc.StaticExports.EnumerateRemoteConnections("localhost"); + + string runningPrograms = ""; + int running = 0; + foreach (var i in idents) + { + if (i != 0) + { + running++; + + var conn = renderdoc.StaticExports.CreateRemoteAccessConnection("localhost", i, "updater", false); + + if (runningPrograms != "") + runningPrograms += "\n"; + + if (conn.API != "") + runningPrograms += String.Format("{0} running {1}", conn.Target, conn.API); + else + runningPrograms += conn.Target; + + conn.Shutdown(); + } + } + + if (running > 0) + { + BeginInvoke((MethodInvoker)delegate + { + progressText.Text = ""; + + close.Enabled = true; + doupdate.Enabled = true; + + MessageBox.Show( + String.Format("RenderDoc is currently capturing, cannot update " + + "until the program{0} closed:\n\n", running > 1 ? "s are" : " is") + + runningPrograms, + "RenderDoc in use", MessageBoxButtons.OK, MessageBoxIcon.Error); + }); + return; + } + + BeginInvoke((MethodInvoker)delegate + { + progressText.Text = "Connecting"; + }); + HttpWebRequest g = (HttpWebRequest)HttpWebRequest.Create(m_URL); g.Method = "GET";