From b955ef0b52003382526256d85dac2b739fe048fd Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 11 Jul 2018 16:03:37 +0100 Subject: [PATCH] Support a NULL window for functions that only need it for dialogs * Primarily useful for Python where threading can cause problems, and there's no need. --- qrenderdoc/Code/Interface/SPIRVDisassembler.cpp | 17 ++++++++++------- qrenderdoc/Code/ReplayManager.cpp | 12 ++++++------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/qrenderdoc/Code/Interface/SPIRVDisassembler.cpp b/qrenderdoc/Code/Interface/SPIRVDisassembler.cpp index 59f72c452..ab2a8198f 100644 --- a/qrenderdoc/Code/Interface/SPIRVDisassembler.cpp +++ b/qrenderdoc/Code/Interface/SPIRVDisassembler.cpp @@ -105,13 +105,16 @@ rdcstr SPIRVDisassembler::DisassembleShader(QWidget *window, const ShaderReflect if(process.exitStatus() != QProcess::NormalExit || process.exitCode() != 0) { - GUIInvoke::call(window, [window]() { - RDDialog::critical( - window, QApplication::translate("SPIRVDisassembler", "Error running disassembler"), - QApplication::translate( - "SPIRVDisassembler", - "There was an error invoking the external SPIR-V disassembler.")); - }); + if(window) + { + GUIInvoke::call(window, [window]() { + RDDialog::critical( + window, QApplication::translate("SPIRVDisassembler", "Error running disassembler"), + QApplication::translate( + "SPIRVDisassembler", + "There was an error invoking the external SPIR-V disassembler.")); + }); + } } if(writesToFile) diff --git a/qrenderdoc/Code/ReplayManager.cpp b/qrenderdoc/Code/ReplayManager.cpp index 193f093a6..03e7f04ef 100644 --- a/qrenderdoc/Code/ReplayManager.cpp +++ b/qrenderdoc/Code/ReplayManager.cpp @@ -165,14 +165,14 @@ rdcstr ReplayManager::CopyCaptureToRemote(const rdcstr &localpath, QWidget *wind rdcstr remotepath; - bool copied = false; + QAtomicInt copied = 0; float progress = 0.0f; auto lambda = [this, localpath, &remotepath, &progress, &copied](IReplayController *r) { QMutexLocker autolock(&m_RemoteLock); remotepath = m_Remote->CopyCaptureToRemote(localpath.c_str(), [&progress](float p) { progress = p; }); - copied = true; + copied = 1; }; // we should never have the thread running at this point, but let's be safe. @@ -187,7 +187,7 @@ rdcstr ReplayManager::CopyCaptureToRemote(const rdcstr &localpath, QWidget *wind thread->start(); } - ShowProgressDialog(window, tr("Transferring..."), [&copied]() { return copied; }, + ShowProgressDialog(window, tr("Transferring..."), [&copied]() { return copied == 0; }, [&progress]() { return progress; }); return remotepath; @@ -199,14 +199,14 @@ void ReplayManager::CopyCaptureFromRemote(const rdcstr &remotepath, const rdcstr if(!m_Remote) return; - bool copied = false; + QAtomicInt copied = 0; float progress = 0.0f; auto lambda = [this, localpath, remotepath, &progress, &copied](IReplayController *r) { QMutexLocker autolock(&m_RemoteLock); m_Remote->CopyCaptureFromRemote(remotepath.c_str(), localpath.c_str(), [&progress](float p) { progress = p; }); - copied = true; + copied = 1; }; // we should never have the thread running at this point, but let's be safe. @@ -221,7 +221,7 @@ void ReplayManager::CopyCaptureFromRemote(const rdcstr &remotepath, const rdcstr thread->start(); } - ShowProgressDialog(window, tr("Transferring..."), [&copied]() { return copied; }, + ShowProgressDialog(window, tr("Transferring..."), [&copied]() { return copied == 0; }, [&progress]() { return progress; }); }