diff --git a/src/plugins/autotest/testrunner.cpp b/src/plugins/autotest/testrunner.cpp index ee188ff647c272393a46196c403bd7c58b6af02a..df6ce4206d74c555f9d5bf6b30a9549920a7d73a 100644 --- a/src/plugins/autotest/testrunner.cpp +++ b/src/plugins/autotest/testrunner.cpp @@ -347,7 +347,7 @@ void TestRunner::debugTests() return; } - (void) new Debugger::DebuggerRunTool(runControl, sp, &errorMessage); + (void) new Debugger::DebuggerRunTool(runControl, sp); bool useOutputProcessor = true; if (ProjectExplorer::Target *targ = config->project()->activeTarget()) { diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp index 8aa0933bee6593fd86e62ab3249f8f39c2aba91a..fd5f944c9f22bc7c80e6e97136cdbf30e8acd669 100644 --- a/src/plugins/debugger/debuggerruncontrol.cpp +++ b/src/plugins/debugger/debuggerruncontrol.cpp @@ -506,26 +506,25 @@ DebuggerRunTool::DebuggerRunTool(RunControl *runControl) }); } -DebuggerRunTool::DebuggerRunTool(RunControl *runControl, const DebuggerStartParameters &sp, QString *errorMessage) +DebuggerRunTool::DebuggerRunTool(RunControl *runControl, const DebuggerStartParameters &sp) : DebuggerRunTool(runControl) { - setStartParameters(sp, errorMessage); + setStartParameters(sp); } -DebuggerRunTool::DebuggerRunTool(RunControl *runControl, const DebuggerRunParameters &rp, QString *errorMessage) +DebuggerRunTool::DebuggerRunTool(RunControl *runControl, const DebuggerRunParameters &rp) : DebuggerRunTool(runControl) { - setRunParameters(rp, errorMessage); + setRunParameters(rp); } -void DebuggerRunTool::setStartParameters(const DebuggerStartParameters &sp, QString *errorMessage) +void DebuggerRunTool::setStartParameters(const DebuggerStartParameters &sp) { - setRunParameters(sp, errorMessage); + setRunParameters(sp); } -void DebuggerRunTool::setRunParameters(const DebuggerRunParameters &rp, QString *errorMessage) +void DebuggerRunTool::setRunParameters(const DebuggerRunParameters &rp) { - Q_UNUSED(errorMessage); m_runParameters = rp; } @@ -618,15 +617,13 @@ public: : IRunControlFactory(parent) {} - RunControl *create(RunConfiguration *runConfig, - Core::Id mode, QString *errorMessage) override + RunControl *create(RunConfiguration *runConfig, Core::Id mode, QString *) override { QTC_ASSERT(runConfig, return 0); QTC_ASSERT(mode == DebugRunMode || mode == DebugRunModeWithBreakOnMain, return 0); - DebuggerStartParameters sp; auto runControl = new RunControl(runConfig, mode); - (void) new DebuggerRunTool(runControl, sp, errorMessage); + (void) new DebuggerRunTool(runControl); return runControl; } diff --git a/src/plugins/debugger/debuggerruncontrol.h b/src/plugins/debugger/debuggerruncontrol.h index 20c28dce648d74926be7bb4819cbdefd6f7f601d..71a72f25b32191a49b6b634f7d179aad8e00b0d0 100644 --- a/src/plugins/debugger/debuggerruncontrol.h +++ b/src/plugins/debugger/debuggerruncontrol.h @@ -44,17 +44,13 @@ public: DebuggerRunTool(ProjectExplorer::RunControl *runControl); // Use. DebuggerRunTool(ProjectExplorer::RunControl *runControl, - const DebuggerStartParameters &sp, - QString *errorMessage = nullptr); // Use rarely. + const DebuggerStartParameters &sp); // Use rarely. DebuggerRunTool(ProjectExplorer::RunControl *runControl, - const Internal::DebuggerRunParameters &rp, - QString *errorMessage = nullptr); // FIXME: Don't use. + const Internal::DebuggerRunParameters &rp); // FIXME: Don't use. ~DebuggerRunTool(); - void setStartParameters(const DebuggerStartParameters &sp, - QString *errorMessage = nullptr); // Use rarely. - void setRunParameters(const Internal::DebuggerRunParameters &rp, - QString *errorMessage = nullptr); // FIXME: Don't use. + void setStartParameters(const DebuggerStartParameters &sp); // Use rarely. + void setRunParameters(const Internal::DebuggerRunParameters &rp); // FIXME: Don't use. Internal::DebuggerEngine *engine() const { return m_engine; } Internal::DebuggerEngine *activeEngine() const; diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index ab597a98fbd948669ad3b13d7d2f45747dfea76b..75df5b6ff6cba9631cc3bb80853bc1fc593270ab 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -1547,7 +1547,12 @@ void RunWorker::setSupportsReRunning(bool reRunningSupported) bool RunWorker::supportsReRunning() const { - return d->supportsReRunning; + return d->supportsReRunning; +} + +bool RunWorker::hasFailed() const +{ + return d->state == RunWorkerState::Failed; } QString RunWorker::userMessageForProcessError(QProcess::ProcessError error, const QString &program) diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index 31c0e88692a8cf9e01b726e5ff241a0af868b3a9..b7a69ca2ebbe6c382ee4d65beffb87c8ed849191 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -361,6 +361,7 @@ public: void reportFailure(const QString &msg = QString()); void setSupportsReRunning(bool reRunningSupported); bool supportsReRunning() const; + bool hasFailed() const; static QString userMessageForProcessError(QProcess::ProcessError, const QString &programName); diff --git a/src/plugins/qnx/qnxattachdebugsupport.cpp b/src/plugins/qnx/qnxattachdebugsupport.cpp index 6cbe3594fdb796cd3d6e50034d57ce1484467c1b..16ef27610df91e5abb77ccd7f991af7dcc309c69 100644 --- a/src/plugins/qnx/qnxattachdebugsupport.cpp +++ b/src/plugins/qnx/qnxattachdebugsupport.cpp @@ -131,18 +131,7 @@ void QnxAttachDebugSupport::attachToProcess() sp.solibSearchPath = QnxUtils::searchPaths(qtVersion); auto runControl = new RunControl(nullptr, ProjectExplorer::Constants::DEBUG_RUN_MODE); - if (!runControl) { - handleError(tr("Attaching failed.")); - stopPDebug(); - return; - } - QString errorMessage; - (void) new Debugger::DebuggerRunTool(runControl, sp, &errorMessage); - if (!errorMessage.isEmpty()) { - handleError(errorMessage); - stopPDebug(); - return; - } + (void) new Debugger::DebuggerRunTool(runControl, sp); // connect(qobject_cast<Debugger::DebuggerRunTool *>(runControl->toolRunner()), // &Debugger::DebuggerRunTool::stateChanged, // this, &QnxAttachDebugSupport::handleDebuggerStateChanged); diff --git a/src/plugins/winrt/winrtdebugsupport.cpp b/src/plugins/winrt/winrtdebugsupport.cpp index 352ac3f3f97f94aec392a6eb2848d66578612e20..7499200df1722437d7a70272dab7a2238a77bdda 100644 --- a/src/plugins/winrt/winrtdebugsupport.cpp +++ b/src/plugins/winrt/winrtdebugsupport.cpp @@ -45,7 +45,7 @@ using namespace ProjectExplorer; namespace WinRt { namespace Internal { -WinRtDebugSupport::WinRtDebugSupport(RunControl *runControl, QString *errorMessage) +WinRtDebugSupport::WinRtDebugSupport(RunControl *runControl) : DebuggerRunTool(runControl) { // FIXME: This is just working for local debugging; @@ -57,35 +57,38 @@ WinRtDebugSupport::WinRtDebugSupport(RunControl *runControl, QString *errorMessa QFileInfo debuggerHelper(QCoreApplication::applicationDirPath() + QLatin1String("/winrtdebughelper.exe")); if (!debuggerHelper.isExecutable()) { - *errorMessage = tr("The WinRT debugging helper is missing from your Qt Creator " - "installation. It was assumed to be located at %1").arg( - debuggerHelper.absoluteFilePath()); + reportFailure(tr("The WinRT debugging helper is missing from your Qt Creator " + "installation. It was assumed to be located at %1").arg( + debuggerHelper.absoluteFilePath())); return; } if (isQmlDebugging()) { Utils::Port qmlDebugPort; - if (!getFreePort(qmlDebugPort, errorMessage)) + if (!getFreePort(qmlDebugPort)) return; params.qmlServer.host = QHostAddress(QHostAddress::LocalHost).toString(); params.qmlServer.port = qmlDebugPort; } - m_runner = new WinRtRunnerHelper(this, errorMessage); - if (!errorMessage->isEmpty()) + QString errorMessage; + m_runner = new WinRtRunnerHelper(this, &errorMessage); + if (!errorMessage.isEmpty()) { + reportFailure(errorMessage); return; + } QLocalServer server; server.listen(QLatin1String("QtCreatorWinRtDebugPIDPipe")); m_runner->debug(debuggerHelper.absoluteFilePath()); if (!m_runner->waitForStarted()) { - *errorMessage = tr("Cannot start the WinRT Runner Tool."); + reportFailure(tr("Cannot start the WinRT Runner Tool.")); return; } if (!server.waitForNewConnection(10000)) { - *errorMessage = tr("Cannot establish connection to the WinRT debugging helper."); + reportFailure(tr("Cannot establish connection to the WinRT debugging helper.")); return; } @@ -98,12 +101,12 @@ WinRtDebugSupport::WinRtDebugSupport(RunControl *runControl, QString *errorMessa bool ok =false; params.attachPID = Utils::ProcessHandle(arg.last().toInt(&ok)); if (!ok) { - *errorMessage = tr("Cannot extract the PID from the WinRT debugging helper. " - "(output: %1)").arg(QString::fromLocal8Bit(output)); + reportFailure(tr("Cannot extract the PID from the WinRT debugging helper. " + "(output: %1)").arg(QString::fromLocal8Bit(output))); return; } server.close(); - setStartParameters(params, errorMessage); + setStartParameters(params); return; } } @@ -111,16 +114,16 @@ WinRtDebugSupport::WinRtDebugSupport(RunControl *runControl, QString *errorMessa server.close(); - *errorMessage = tr("Cannot create an appropriate run control for " - "the current run configuration."); + reportFailure(tr("Cannot create an appropriate run control for " + "the current run configuration.")); } -bool WinRtDebugSupport::getFreePort(Utils::Port &qmlDebuggerPort, QString *errorMessage) +bool WinRtDebugSupport::getFreePort(Utils::Port &qmlDebuggerPort) { QTcpServer server; if (!server.listen(QHostAddress::LocalHost, qmlDebuggerPort.isValid() ? qmlDebuggerPort.number() : 0)) { - *errorMessage = tr("Not enough free ports for QML debugging."); + reportFailure(tr("Not enough free ports for QML debugging.")); return false; } qmlDebuggerPort = Utils::Port(server.serverPort()); diff --git a/src/plugins/winrt/winrtdebugsupport.h b/src/plugins/winrt/winrtdebugsupport.h index 995c3a0b73fb3a99c3fc928c8159b931000c837c..0a8ed4e31ab12a95c4010d66036a4bb9d60203b6 100644 --- a/src/plugins/winrt/winrtdebugsupport.h +++ b/src/plugins/winrt/winrtdebugsupport.h @@ -38,11 +38,11 @@ class WinRtDebugSupport : public Debugger::DebuggerRunTool Q_OBJECT public: - WinRtDebugSupport(ProjectExplorer::RunControl *runControl, QString *errorMessage); + explicit WinRtDebugSupport(ProjectExplorer::RunControl *runControl); ~WinRtDebugSupport(); private: - static bool getFreePort(Utils::Port &qmlDebuggerPort, QString *errorMessage); + bool getFreePort(Utils::Port &qmlDebuggerPort); WinRtRunnerHelper *m_runner = nullptr; }; diff --git a/src/plugins/winrt/winrtrunfactories.cpp b/src/plugins/winrt/winrtrunfactories.cpp index af4914c9bd1d8ab773d1a58128fc16394d652c85..3269b32d641b54a167673490629c155deb442339 100644 --- a/src/plugins/winrt/winrtrunfactories.cpp +++ b/src/plugins/winrt/winrtrunfactories.cpp @@ -151,7 +151,7 @@ bool WinRtRunControlFactory::canRun(RunConfiguration *runConfiguration, } RunControl *WinRtRunControlFactory::create( - RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage) + RunConfiguration *runConfiguration, Core::Id mode, QString *) { RunControl *runControl = nullptr; if (mode == ProjectExplorer::Constants::NORMAL_RUN_MODE) { @@ -161,15 +161,10 @@ RunControl *WinRtRunControlFactory::create( } else if (mode == ProjectExplorer::Constants::DEBUG_RUN_MODE || mode == ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN) { runControl = new RunControl(runConfiguration, mode); - (void) new WinRtDebugSupport(runControl, errorMessage); - } else { - *errorMessage = tr("Unsupported run mode %1.").arg(mode.toString()); - } - - if (errorMessage->isEmpty()) + (void) new WinRtDebugSupport(runControl); return runControl; + } - delete runControl; return nullptr; }