From 7a1cc84f41430a3dd89bb01f1b41c378bd7f0b67 Mon Sep 17 00:00:00 2001 From: baldurk Date: Sun, 12 Apr 2015 18:37:16 +0100 Subject: [PATCH] Keep temporary log around to be able to save multiple times. Closes #130 * Previously if a temporary log was saved once, it would be moved there, so the user could in theory delete it and lose the only copy of the log. * Now the temporary log is held until it's closed in the UI, to be able to be saved again. If the user saves the log though, this will stop any "unsaved log" prompts in the main UI window, so there is nothing stopping the user from saving the log, deleting that copy, then closing and they'll lose the log without prompt. --- renderdocui/Windows/Dialogs/LiveCapture.cs | 6 ++---- renderdocui/Windows/MainWindow.cs | 22 ++++++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/renderdocui/Windows/Dialogs/LiveCapture.cs b/renderdocui/Windows/Dialogs/LiveCapture.cs index 7def705d7..3962e1eaa 100644 --- a/renderdocui/Windows/Dialogs/LiveCapture.cs +++ b/renderdocui/Windows/Dialogs/LiveCapture.cs @@ -386,13 +386,11 @@ namespace renderdocui.Windows string path = m_Main.GetSavePath(); + // we copy the temp log to the desired path, but the log item remains referring to the temp path. + // This ensures that if the user deletes the saved path we can still open or re-save it. if (path.Length > 0) { File.Copy(log.localpath, path, true); - File.Delete(log.localpath); - - log.localpath = path; - log.saved = true; return true; } diff --git a/renderdocui/Windows/MainWindow.cs b/renderdocui/Windows/MainWindow.cs index 1739f35c6..96f6e6e40 100644 --- a/renderdocui/Windows/MainWindow.cs +++ b/renderdocui/Windows/MainWindow.cs @@ -829,6 +829,7 @@ namespace renderdocui.Windows } public bool OwnTemporaryLog = false; + private bool SavedTemporaryLog = false; public void ShowLiveCapture(LiveCapture live) { @@ -1041,7 +1042,11 @@ namespace renderdocui.Windows { string temppath = m_Core.LogFileName; - DialogResult res = MessageBox.Show("Save this logfile?", "Unsaved log", MessageBoxButtons.YesNoCancel); + DialogResult res = DialogResult.No; + + // unless we've saved the log, prompt to save + if(!SavedTemporaryLog) + res = MessageBox.Show("Save this logfile?", "Unsaved log", MessageBoxButtons.YesNoCancel); if (res == DialogResult.Cancel) { @@ -1061,6 +1066,7 @@ namespace renderdocui.Windows if (temppath != m_Core.LogFileName || res == DialogResult.No) deletepath = temppath; OwnTemporaryLog = false; + SavedTemporaryLog = false; } CloseLogfile(); @@ -1084,17 +1090,13 @@ namespace renderdocui.Windows return false; } + // we copy the (possibly) temp log to the desired path, but the log item remains referring to the original path. + // This ensures that if the user deletes the saved path we can still open or re-save it. File.Copy(m_Core.LogFileName, saveDialog.FileName, true); - OwnTemporaryLog = false; - - m_Core.LogFileName = saveDialog.FileName; - - SetTitle(); - - m_Core.Config.AddRecentFile(m_Core.Config.RecentLogFiles, m_Core.LogFileName, 10); - - PopulateRecentFiles(); + // we don't prompt to save on closing - if the user deleted the log that we just saved, then + // that is up to them. + SavedTemporaryLog = true; return true; }