diff --git a/qrenderdoc/Code/CaptureContext.cpp b/qrenderdoc/Code/CaptureContext.cpp index c3e2ee7dc..d9a3834d1 100644 --- a/qrenderdoc/Code/CaptureContext.cpp +++ b/qrenderdoc/Code/CaptureContext.cpp @@ -63,9 +63,7 @@ #include "pipestate.inl" -CaptureContext::CaptureContext(QString paramFilename, QString remoteHost, uint32_t remoteIdent, - bool temp, PersistantConfig &cfg) - : m_Config(cfg) +CaptureContext::CaptureContext(PersistantConfig &cfg) : m_Config(cfg) { m_CaptureLoaded = false; m_LoadInProgress = false; @@ -90,25 +88,6 @@ CaptureContext::CaptureContext(QString paramFilename, QString remoteHost, uint32 m_Icon->addFile(QStringLiteral(":/logo.svg"), QSize(), QIcon::Normal, QIcon::Off); m_MainWindow = new MainWindow(*this); - m_MainWindow->show(); - - if(remoteIdent != 0) - { - m_MainWindow->ShowLiveCapture( - new LiveCapture(*this, remoteHost, remoteHost, remoteIdent, m_MainWindow, m_MainWindow)); - } - - if(!paramFilename.isEmpty()) - { - QFileInfo checkFile(paramFilename); - - if(checkFile.exists() && checkFile.isFile()) - { - m_MainWindow->LoadFromFilename(paramFilename, temp); - if(temp) - m_MainWindow->takeCaptureOwnership(); - } - } { QDir dir(configFilePath("extensions")); @@ -137,6 +116,29 @@ CaptureContext::~CaptureContext() delete m_MainWindow; } +void CaptureContext::Begin(QString paramFilename, QString remoteHost, uint32_t remoteIdent, bool temp) +{ + m_MainWindow->show(); + + if(remoteIdent != 0) + { + m_MainWindow->ShowLiveCapture( + new LiveCapture(*this, remoteHost, remoteHost, remoteIdent, m_MainWindow, m_MainWindow)); + } + + if(!paramFilename.isEmpty()) + { + QFileInfo checkFile(paramFilename); + + if(checkFile.exists() && checkFile.isFile()) + { + m_MainWindow->LoadFromFilename(paramFilename, temp); + if(temp) + m_MainWindow->takeCaptureOwnership(); + } + } +} + bool CaptureContext::isRunning() { return m_MainWindow && m_MainWindow->isVisible(); diff --git a/qrenderdoc/Code/CaptureContext.h b/qrenderdoc/Code/CaptureContext.h index 321d65ef1..bea3b07fd 100644 --- a/qrenderdoc/Code/CaptureContext.h +++ b/qrenderdoc/Code/CaptureContext.h @@ -58,10 +58,10 @@ class CaptureContext : public ICaptureContext, IExtensionManager Q_DECLARE_TR_FUNCTIONS(CaptureContext); public: - CaptureContext(QString paramFilename, QString remoteHost, uint32_t remoteIdent, bool temp, - PersistantConfig &cfg); + CaptureContext(PersistantConfig &cfg); ~CaptureContext(); + void Begin(QString paramFilename, QString remoteHost, uint32_t remoteIdent, bool temp); bool isRunning(); rdcstr TempCaptureFilename(const rdcstr &appname) override; diff --git a/qrenderdoc/Code/qrenderdoc.cpp b/qrenderdoc/Code/qrenderdoc.cpp index 76d97bacc..a35dbaf1f 100644 --- a/qrenderdoc/Code/qrenderdoc.cpp +++ b/qrenderdoc/Code/qrenderdoc.cpp @@ -435,7 +435,7 @@ int main(int argc, char *argv[]) config.Save(); } - CaptureContext ctx(filename, remoteHost, remoteIdent, temp, config); + CaptureContext ctx(config); if(replayHostIndex >= 0) { ctx.SetRemoteHost(replayHostIndex); @@ -457,6 +457,8 @@ int main(int argc, char *argv[]) ANALYTIC_SET(Metadata.DaysUsed[QDateTime::currentDateTime().date().day()], true); + bool pythonExited = false; + if(!pyscripts.isEmpty()) { PythonContextHandle py; @@ -465,22 +467,29 @@ int main(int argc, char *argv[]) py.ctx().setGlobal("pyrenderdoc", (ICaptureContext *)&ctx); - QObject::connect(&py.ctx(), &PythonContext::exception, - [](const QString &type, const QString &value, int, QList frames) { + QObject::connect( + &py.ctx(), &PythonContext::exception, + [&pythonExited](const QString &type, const QString &value, int, QList frames) { - QString exString; + if(type == lit("SystemExit")) + { + pythonExited = true; + return; + } - if(!frames.isEmpty()) - { - exString += tr("Traceback (most recent call last):\n"); - for(const QString &f : frames) - exString += QFormatStr(" %1\n").arg(f); - } + QString exString; - exString += QFormatStr("%1: %2\n").arg(type).arg(value); + if(!frames.isEmpty()) + { + exString += tr("Traceback (most recent call last):\n"); + for(const QString &f : frames) + exString += QFormatStr(" %1\n").arg(f); + } - qCritical("%s", exString.toUtf8().data()); - }); + exString += QFormatStr("%1: %2\n").arg(type).arg(value); + + qCritical("%s", exString.toUtf8().data()); + }); QObject::connect(&py.ctx(), &PythonContext::textOutput, [](bool isStdError, const QString &output) { @@ -502,14 +511,22 @@ int main(int argc, char *argv[]) { qWarning() << "Invalid python script" << f; } + + if(pythonExited) + break; } } - while(ctx.isRunning()) + if(!pythonExited) { - application.processEvents(QEventLoop::WaitForMoreEvents); - QCoreApplication::sendPostedEvents(); - QCoreApplication::sendPostedEvents(NULL, QEvent::DeferredDelete); + ctx.Begin(filename, remoteHost, remoteIdent, temp); + + while(ctx.isRunning()) + { + application.processEvents(QEventLoop::WaitForMoreEvents); + QCoreApplication::sendPostedEvents(); + QCoreApplication::sendPostedEvents(NULL, QEvent::DeferredDelete); + } } config.Save();