From 2752008d130fd32675914a9b4931df899f40fbc5 Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 14 Sep 2021 13:25:02 +0100 Subject: [PATCH] Ensure consistency when saving the current capture. Closes #2358 * If we save the current capture from a connection window we want to do that via the main window so the UI can be properly updated and so we can save it properly through the replay manager, so the old one can be removed safely. --- qrenderdoc/Windows/Dialogs/LiveCapture.cpp | 10 ++++++ qrenderdoc/Windows/MainWindow.cpp | 39 ++++++++++++---------- qrenderdoc/Windows/MainWindow.h | 6 ++-- 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/qrenderdoc/Windows/Dialogs/LiveCapture.cpp b/qrenderdoc/Windows/Dialogs/LiveCapture.cpp index 489dde722..49e5aabda 100644 --- a/qrenderdoc/Windows/Dialogs/LiveCapture.cpp +++ b/qrenderdoc/Windows/Dialogs/LiveCapture.cpp @@ -801,6 +801,16 @@ void LiveCapture::openCapture(Capture *cap) bool LiveCapture::saveCapture(Capture *cap, QString path) { + // if this is the current capture, do the save through the main window + if(QString(m_Ctx.GetCaptureFilename()) == cap->path) + { + // if there's no target path, let the main window prompt for save. + if(path.isEmpty()) + return m_Main->PromptSaveCaptureAs(); + else + return m_Main->SaveCurrentCapture(path); + } + if(path.isEmpty()) { path = m_Main->GetSavePath(); diff --git a/qrenderdoc/Windows/MainWindow.cpp b/qrenderdoc/Windows/MainWindow.cpp index 3a1033d01..3210a4653 100644 --- a/qrenderdoc/Windows/MainWindow.cpp +++ b/qrenderdoc/Windows/MainWindow.cpp @@ -1004,27 +1004,32 @@ bool MainWindow::PromptSaveCaptureAs() QString saveFilename = GetSavePath(); if(!saveFilename.isEmpty()) - { - QString origFilename = m_Ctx.GetCaptureFilename(); - - bool success = m_Ctx.SaveCaptureTo(saveFilename); - - if(!success) - return false; - - AddRecentFile(m_Ctx.Config().RecentCaptureFiles, saveFilename); - PopulateRecentCaptureFiles(); - SetTitle(saveFilename); - - for(LiveCapture *live : m_LiveCaptures) - live->fileSaved(origFilename, saveFilename); - - return true; - } + return SaveCurrentCapture(saveFilename); return false; } +bool MainWindow::SaveCurrentCapture(QString saveFilename) +{ + QString origFilename = m_Ctx.GetCaptureFilename(); + + bool success = m_Ctx.SaveCaptureTo(saveFilename); + + if(!success) + return false; + + AddRecentFile(m_Ctx.Config().RecentCaptureFiles, saveFilename); + PopulateRecentCaptureFiles(); + SetTitle(saveFilename); + + for(LiveCapture *live : m_LiveCaptures) + live->fileSaved(origFilename, saveFilename); + + ui->action_Save_Capture_Inplace->setEnabled(false); + + return true; +} + void MainWindow::exportCapture(const CaptureFileFormat &fmt) { if(!m_Ctx.IsCaptureLocal()) diff --git a/qrenderdoc/Windows/MainWindow.h b/qrenderdoc/Windows/MainWindow.h index 5edf94983..0180137b7 100644 --- a/qrenderdoc/Windows/MainWindow.h +++ b/qrenderdoc/Windows/MainWindow.h @@ -115,6 +115,10 @@ public: void ShowLiveCapture(LiveCapture *live); void LiveCaptureClosed(LiveCapture *live); + bool PromptCloseCapture(); + bool PromptSaveCaptureAs(); + bool SaveCurrentCapture(QString saveFilename); + void RemoveRecentCapture(const QString &filename); QMenu *GetBaseMenu(WindowMenu base, rdcstr name); @@ -279,8 +283,6 @@ private: void recentCaptureFile(const QString &filename); void recentCaptureSetting(const QString &filename); - bool PromptCloseCapture(); - bool PromptSaveCaptureAs(); void OpenCaptureConfigFile(const QString &filename, bool exe); QVariantMap saveState();