From 3587f8e4488ea56c5d4e427f37fd7166c1851b6d Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 11 Jan 2022 11:42:16 +0000 Subject: [PATCH] When closing multiple capture connections apply 'No to All' answer wider * This means if you're closing multiple connections and click 'no to all' when prompting save of instead of discarding just the captures in that connection then going on to prompt for the next, it discards all remaining captures. --- qrenderdoc/Windows/Dialogs/LiveCapture.cpp | 32 +++++++++++++++++++--- qrenderdoc/Windows/Dialogs/LiveCapture.h | 1 + qrenderdoc/Windows/MainWindow.cpp | 18 ++++++++++-- 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/qrenderdoc/Windows/Dialogs/LiveCapture.cpp b/qrenderdoc/Windows/Dialogs/LiveCapture.cpp index 49e5aabda..91f520d1f 100644 --- a/qrenderdoc/Windows/Dialogs/LiveCapture.cpp +++ b/qrenderdoc/Windows/Dialogs/LiveCapture.cpp @@ -685,12 +685,11 @@ QString LiveCapture::MakeText(Capture *cap) return text; } -bool LiveCapture::checkAllowClose() +bool LiveCapture::checkAllowClose(bool multipleClosures, bool &noToAll) { m_IgnoreThreadClosed = true; bool suppressRemoteWarning = false; - bool notoall = false; QMessageBox::StandardButtons msgFlags = RDDialog::YesNoCancel; @@ -712,7 +711,7 @@ bool LiveCapture::checkAllowClose() QMessageBox::StandardButton res = QMessageBox::No; - if(!suppressRemoteWarning && !notoall) + if(!suppressRemoteWarning && !noToAll) { QString frameName = tr("Frame #%1").arg(cap->frameNumber); if(cap->frameNumber == ~0U) @@ -727,7 +726,26 @@ bool LiveCapture::checkAllowClose() if(res == QMessageBox::NoToAll) { - notoall = true; + // if we're closing multiple connections make sure the user is sure of what they're doing + if(multipleClosures) + { + QMessageBox::StandardButton res2 = + RDDialog::question(this, tr("Discarding all captures"), + tr("Multiple connections open have potentially unsaved captures, " + "are you sure you wish to discard them all?")); + + // if the user is sure, apply the no to all + if(res2 == QMessageBox::Yes) + noToAll = true; + + // otherwise we'll treat this as a simple 'no' in case they changed their mind. + } + else + { + // if we're not closing multiple, we can just immediately accept the 'no to all' + noToAll = true; + } + res = QMessageBox::No; } } @@ -782,6 +800,12 @@ bool LiveCapture::checkAllowClose() return true; } +bool LiveCapture::checkAllowClose() +{ + bool dummy = false; + return checkAllowClose(false, dummy); +} + void LiveCapture::openCapture(Capture *cap) { cap->opened = true; diff --git a/qrenderdoc/Windows/Dialogs/LiveCapture.h b/qrenderdoc/Windows/Dialogs/LiveCapture.h index 019ac5660..97e3cd575 100644 --- a/qrenderdoc/Windows/Dialogs/LiveCapture.h +++ b/qrenderdoc/Windows/Dialogs/LiveCapture.h @@ -61,6 +61,7 @@ public: const QString &hostname() { return m_Hostname; } void cleanItems(); void fileSaved(QString from, QString to); + bool checkAllowClose(bool multipleClosures, bool &noToAll); public slots: bool checkAllowClose(); diff --git a/qrenderdoc/Windows/MainWindow.cpp b/qrenderdoc/Windows/MainWindow.cpp index 3210a4653..23ef0ddc9 100644 --- a/qrenderdoc/Windows/MainWindow.cpp +++ b/qrenderdoc/Windows/MainWindow.cpp @@ -1951,6 +1951,8 @@ void MainWindow::setRemoteHost(int hostIdx) if(hostIdx >= 0 && hostIdx < hosts.count()) host = hosts[hostIdx]; + bool noToAll = false; + for(LiveCapture *live : m_LiveCaptures) { // allow live captures to this host to stay open, that way @@ -1959,7 +1961,12 @@ void MainWindow::setRemoteHost(int hostIdx) if(host.IsValid() && live->hostname() == host.Hostname()) continue; - if(!live->checkAllowClose()) + // if the user previously selected 'no to all' in the save prompts below, apply that to all + // subsequent live captures + if(noToAll) + continue; + + if(!live->checkAllowClose(m_LiveCaptures.count() > 1, noToAll)) return; } @@ -2937,9 +2944,16 @@ void MainWindow::loadLayout_triggered() void MainWindow::closeEvent(QCloseEvent *event) { + bool noToAll = false; + for(LiveCapture *live : m_LiveCaptures) { - if(!live->checkAllowClose()) + // if the user previously selected 'no to all' in the save prompts below, apply that to all + // subsequent live captures + if(noToAll) + continue; + + if(!live->checkAllowClose(m_LiveCaptures.count() > 1, noToAll)) { event->ignore(); return;