From a875a33f7f15799026aeb08a06e84ba0537c8a69 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 29 Aug 2016 20:28:25 +0200 Subject: [PATCH] Display a prompt if a capture file is about to be lost/leaked * This can happen if the program is closed, and no remote replay context is active. Unlikely locally, the UI cannot natively save or delete temporary captures. --- renderdocui/Windows/Dialogs/LiveCapture.cs | 37 ++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/renderdocui/Windows/Dialogs/LiveCapture.cs b/renderdocui/Windows/Dialogs/LiveCapture.cs index 69dcf1ce5..f1c585b4d 100644 --- a/renderdocui/Windows/Dialogs/LiveCapture.cs +++ b/renderdocui/Windows/Dialogs/LiveCapture.cs @@ -407,6 +407,8 @@ namespace renderdocui.Windows { m_IgnoreThreadClosed = true; + bool suppressRemoteWarning = false; + foreach (ListViewItem i in captures.Items) { var log = i.Tag as CaptureLog; @@ -418,8 +420,13 @@ namespace renderdocui.Windows captures.Focus(); i.Selected = true; - DialogResult res = MessageBox.Show(String.Format("Save this logfile from {0} at {1}?", log.exe, log.timestamp.ToString("T")), - "Unsaved log", MessageBoxButtons.YesNoCancel); + DialogResult res = DialogResult.No; + + if (!suppressRemoteWarning) + { + res = MessageBox.Show(String.Format("Save this logfile from {0} at {1}?", log.exe, log.timestamp.ToString("T")), + "Unsaved log", MessageBoxButtons.YesNoCancel); + } if (res == DialogResult.Cancel) { @@ -427,6 +434,32 @@ namespace renderdocui.Windows return false; } + // we either have to save or delete the log. Make sure that if it's remote that we are able + // to by having an active replay context on that host. + if (suppressRemoteWarning == false && + (m_Core.Renderer.Remote == null || + m_Core.Renderer.Remote.Hostname != m_Host || + !m_Core.Renderer.Remote.Connected) + ) + { + DialogResult res2 = MessageBox.Show( + String.Format("This connection is to a remote host {0} and there is no active replay context on that host.\n", m_Host) + + "Without an active replay context the capture cannot be " + (res == DialogResult.Yes ? "saved.\n\n" : "deleted.\n\n") + + "Would you like to continue and discard this capture and any others, to be left in the temporary folder on the remote machine?", + "No active replay context", MessageBoxButtons.YesNoCancel); + + if (res2 == DialogResult.Yes) + { + suppressRemoteWarning = true; + res = DialogResult.No; + } + else + { + m_IgnoreThreadClosed = false; + return false; + } + } + if (res == DialogResult.Yes) { bool success = SaveCapture(log);