diff options
author | hjk <hjk@qt.io> | 2017-03-28 09:07:29 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2017-03-28 14:50:05 +0000 |
commit | 2a1e7cb9f56f728d9bfda85d6a559fc3dc1aa436 (patch) | |
tree | 53276bd5b5548c218c05943aa6ab5f3b1a484e32 | |
parent | a5574bc8029e931c75504f4f82f1bfd421df32f0 (diff) |
RemoteLinux: Base AbstractLinuxRunSupport on PE::ToolSupport
This continues the quest started with eb0b0f944.
This also moves the AnalyzerRunControl::starting signal to the
base, similar to the already present started and finished
signals. Moving emission of the signal to the base is left
to a follow-up patch to keep this here small.
Change-Id: I12e04823df22e7667a4d0a9ee7412153180c60cc
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
10 files changed, 56 insertions, 56 deletions
diff --git a/src/plugins/debugger/analyzer/analyzerruncontrol.h b/src/plugins/debugger/analyzer/analyzerruncontrol.h index 2fc47727dbd..f2f6eaf3631 100644 --- a/src/plugins/debugger/analyzer/analyzerruncontrol.h +++ b/src/plugins/debugger/analyzer/analyzerruncontrol.h @@ -49,9 +49,6 @@ public: virtual void notifyRemoteSetupDone(Utils::Port) {} virtual void notifyRemoteSetupFailed(const QString &) {} virtual void notifyRemoteFinished() {} - -signals: - void starting(); }; } // namespace Debugger diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 409bac15a9d..cf0d157c6de 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -989,4 +989,9 @@ RunControl *ToolRunner::runControl() const return m_runControl; } +void ToolRunner::appendMessage(const QString &msg, OutputFormat format) +{ + m_runControl->appendMessage(msg, format); +} + } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index 9fb582b20d7..82903a691f8 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -407,6 +407,7 @@ public: signals: void appendMessageRequested(ProjectExplorer::RunControl *runControl, const QString &msg, Utils::OutputFormat format); + void starting(); void started(QPrivateSignal); // Use reportApplicationStart! void finished(QPrivateSignal); // Use reportApplicationStop! void applicationProcessHandleChanged(QPrivateSignal); // Use setApplicationProcessHandle @@ -458,6 +459,7 @@ public: explicit ToolRunner(RunControl *runControl); RunControl *runControl() const; + void appendMessage(const QString &msg, Utils::OutputFormat format); private: QPointer<RunControl> m_runControl; diff --git a/src/plugins/remotelinux/abstractremotelinuxrunsupport.cpp b/src/plugins/remotelinux/abstractremotelinuxrunsupport.cpp index 88c3300235d..0c3617113b9 100644 --- a/src/plugins/remotelinux/abstractremotelinuxrunsupport.cpp +++ b/src/plugins/remotelinux/abstractremotelinuxrunsupport.cpp @@ -62,9 +62,9 @@ public: using namespace Internal; -AbstractRemoteLinuxRunSupport::AbstractRemoteLinuxRunSupport(RunConfiguration *runConfig, QObject *parent) - : QObject(parent), - d(new AbstractRemoteLinuxRunSupportPrivate(runConfig)) +AbstractRemoteLinuxRunSupport::AbstractRemoteLinuxRunSupport(RunControl *runControl) + : ToolRunner(runControl), + d(new AbstractRemoteLinuxRunSupportPrivate(runControl->runConfiguration())) { } diff --git a/src/plugins/remotelinux/abstractremotelinuxrunsupport.h b/src/plugins/remotelinux/abstractremotelinuxrunsupport.h index 453f9cdc08f..dbf7440f666 100644 --- a/src/plugins/remotelinux/abstractremotelinuxrunsupport.h +++ b/src/plugins/remotelinux/abstractremotelinuxrunsupport.h @@ -28,6 +28,8 @@ #include "remotelinux_export.h" #include <projectexplorer/devicesupport/idevice.h> +#include <projectexplorer/runconfiguration.h> + #include <utils/port.h> #include <QObject> @@ -43,7 +45,7 @@ namespace RemoteLinux { namespace Internal { class AbstractRemoteLinuxRunSupportPrivate; } -class REMOTELINUX_EXPORT AbstractRemoteLinuxRunSupport : public QObject +class REMOTELINUX_EXPORT AbstractRemoteLinuxRunSupport : public ProjectExplorer::ToolRunner { Q_OBJECT protected: @@ -55,8 +57,7 @@ protected: Running }; public: - AbstractRemoteLinuxRunSupport(ProjectExplorer::RunConfiguration *runConfig, - QObject *parent = 0); + explicit AbstractRemoteLinuxRunSupport(ProjectExplorer::RunControl *runControl); ~AbstractRemoteLinuxRunSupport(); protected: diff --git a/src/plugins/remotelinux/remotelinuxanalyzesupport.cpp b/src/plugins/remotelinux/remotelinuxanalyzesupport.cpp index 9286d0d17c8..93328fe8d98 100644 --- a/src/plugins/remotelinux/remotelinuxanalyzesupport.cpp +++ b/src/plugins/remotelinux/remotelinuxanalyzesupport.cpp @@ -54,9 +54,8 @@ namespace Internal { class RemoteLinuxAnalyzeSupportPrivate { public: - RemoteLinuxAnalyzeSupportPrivate(AnalyzerRunControl *rc, Core::Id runMode) - : runControl(rc), - runMode(runMode) + RemoteLinuxAnalyzeSupportPrivate(RunControl *runControl, Core::Id runMode) + : runMode(runMode) { if (runMode != ProjectExplorer::Constants::PERFPROFILER_RUN_MODE) return; @@ -70,7 +69,6 @@ public: .join(' '); } - const QPointer<AnalyzerRunControl> runControl; Core::Id runMode; Utils::Port qmlPort; QString remoteFifo; @@ -84,16 +82,15 @@ public: using namespace Internal; -RemoteLinuxAnalyzeSupport::RemoteLinuxAnalyzeSupport(RunConfiguration *runConfig, - AnalyzerRunControl *engine, Core::Id runMode) - : AbstractRemoteLinuxRunSupport(runConfig, engine), - d(new RemoteLinuxAnalyzeSupportPrivate(engine, runMode)) +RemoteLinuxAnalyzeSupport::RemoteLinuxAnalyzeSupport(RunControl *runControl, Core::Id runMode) + : AbstractRemoteLinuxRunSupport(runControl), + d(new RemoteLinuxAnalyzeSupportPrivate(runControl, runMode)) { - connect(d->runControl.data(), &AnalyzerRunControl::starting, + connect(runControl, &RunControl::starting, this, &RemoteLinuxAnalyzeSupport::handleRemoteSetupRequested); connect(&d->outputParser, &QmlDebug::QmlOutputParser::waitingForConnectionOnPort, this, &RemoteLinuxAnalyzeSupport::remoteIsRunning); - connect(engine, &RunControl::finished, + connect(runControl, &RunControl::finished, this, &RemoteLinuxAnalyzeSupport::handleProfilingFinished); } @@ -104,8 +101,8 @@ RemoteLinuxAnalyzeSupport::~RemoteLinuxAnalyzeSupport() void RemoteLinuxAnalyzeSupport::showMessage(const QString &msg, Utils::OutputFormat format) { - if (state() != Inactive && d->runControl) - d->runControl->appendMessage(msg, format); + if (state() != Inactive) + appendMessage(msg, format); d->outputParser.processOutput(msg); } @@ -173,9 +170,9 @@ void RemoteLinuxAnalyzeSupport::startExecution() r.executable = QLatin1String("sh"); connect(&d->outputGatherer, SIGNAL(remoteStdout(QByteArray)), - d->runControl, SIGNAL(analyzePerfOutput(QByteArray))); + runControl(), SIGNAL(analyzePerfOutput(QByteArray))); connect(&d->outputGatherer, SIGNAL(finished(bool)), - d->runControl, SIGNAL(perfFinished())); + runControl(), SIGNAL(perfFinished())); StandardRunnable outputRunner; outputRunner.executable = QLatin1String("sh"); @@ -201,7 +198,9 @@ void RemoteLinuxAnalyzeSupport::handleAppRunnerFinished(bool success) reset(); if (!success) showMessage(tr("Failure running remote process."), Utils::NormalMessageFormat); - d->runControl->notifyRemoteFinished(); + auto rc = qobject_cast<AnalyzerRunControl *>(runControl()); + QTC_ASSERT(rc, return); + rc->notifyRemoteFinished(); } void RemoteLinuxAnalyzeSupport::handleProfilingFinished() @@ -211,7 +210,9 @@ void RemoteLinuxAnalyzeSupport::handleProfilingFinished() void RemoteLinuxAnalyzeSupport::remoteIsRunning() { - d->runControl->notifyRemoteSetupDone(d->qmlPort); + auto rc = qobject_cast<AnalyzerRunControl *>(runControl()); + QTC_ASSERT(rc, return); + rc->notifyRemoteSetupDone(d->qmlPort); } void RemoteLinuxAnalyzeSupport::handleRemoteOutput(const QByteArray &output) @@ -225,9 +226,6 @@ void RemoteLinuxAnalyzeSupport::handleRemoteErrorOutput(const QByteArray &output { QTC_ASSERT(state() != GatheringResources, return); - if (!d->runControl) - return; - showMessage(QString::fromUtf8(output), Utils::StdErrFormat); } diff --git a/src/plugins/remotelinux/remotelinuxanalyzesupport.h b/src/plugins/remotelinux/remotelinuxanalyzesupport.h index 25eab27a7a9..21160b316e1 100644 --- a/src/plugins/remotelinux/remotelinuxanalyzesupport.h +++ b/src/plugins/remotelinux/remotelinuxanalyzesupport.h @@ -42,8 +42,7 @@ class REMOTELINUX_EXPORT RemoteLinuxAnalyzeSupport : public AbstractRemoteLinuxR { Q_OBJECT public: - RemoteLinuxAnalyzeSupport(ProjectExplorer::RunConfiguration *runConfig, - Debugger::AnalyzerRunControl *engine, Core::Id runMode); + RemoteLinuxAnalyzeSupport(ProjectExplorer::RunControl *runConfig, Core::Id runMode); ~RemoteLinuxAnalyzeSupport() override; protected: diff --git a/src/plugins/remotelinux/remotelinuxdebugsupport.cpp b/src/plugins/remotelinux/remotelinuxdebugsupport.cpp index f595b1c2919..296d325858e 100644 --- a/src/plugins/remotelinux/remotelinuxdebugsupport.cpp +++ b/src/plugins/remotelinux/remotelinuxdebugsupport.cpp @@ -56,14 +56,12 @@ namespace Internal { class LinuxDeviceDebugSupportPrivate { public: - LinuxDeviceDebugSupportPrivate(const RunConfiguration *runConfig, DebuggerRunControl *runControl) - : runControl(runControl), - qmlDebugging(runConfig->extraAspect<DebuggerRunConfigurationAspect>()->useQmlDebugger()), + LinuxDeviceDebugSupportPrivate(const RunConfiguration *runConfig) + : qmlDebugging(runConfig->extraAspect<DebuggerRunConfigurationAspect>()->useQmlDebugger()), cppDebugging(runConfig->extraAspect<DebuggerRunConfigurationAspect>()->useCppDebugger()) { } - const QPointer<DebuggerRunControl> runControl; bool qmlDebugging; bool cppDebugging; QByteArray gdbserverOutput; @@ -75,12 +73,11 @@ public: using namespace Internal; -LinuxDeviceDebugSupport::LinuxDeviceDebugSupport(RunConfiguration *runConfig, - DebuggerRunControl *runControl) - : AbstractRemoteLinuxRunSupport(runConfig, runControl), - d(new LinuxDeviceDebugSupportPrivate(runConfig, runControl)) +LinuxDeviceDebugSupport::LinuxDeviceDebugSupport(RunControl *runControl) + : AbstractRemoteLinuxRunSupport(runControl), + d(new LinuxDeviceDebugSupportPrivate(runControl->runConfiguration())) { - connect(runControl, &DebuggerRunControl::requestRemoteSetup, + connect(this->runControl(), &DebuggerRunControl::requestRemoteSetup, this, &LinuxDeviceDebugSupport::handleRemoteSetupRequested); connect(runControl, &RunControl::finished, this, &LinuxDeviceDebugSupport::handleDebuggingFinished); @@ -103,8 +100,13 @@ bool LinuxDeviceDebugSupport::isQmlDebugging() const void LinuxDeviceDebugSupport::showMessage(const QString &msg, int channel) { - if (state() != Inactive && d->runControl) - d->runControl->showMessage(msg, channel); + if (state() != Inactive) + runControl()->showMessage(msg, channel); +} + +DebuggerRunControl *LinuxDeviceDebugSupport::runControl() const +{ + return qobject_cast<DebuggerRunControl *>(AbstractRemoteLinuxRunSupport::runControl()); } void LinuxDeviceDebugSupport::handleRemoteSetupRequested() @@ -183,8 +185,7 @@ void LinuxDeviceDebugSupport::handleAppRunnerError(const QString &error) { if (state() == Running) { showMessage(error, AppError); - if (d->runControl) - d->runControl->notifyInferiorIll(); + runControl()->notifyInferiorIll(); } else if (state() != Inactive) { handleAdapterSetupFailed(error); } @@ -192,21 +193,21 @@ void LinuxDeviceDebugSupport::handleAppRunnerError(const QString &error) void LinuxDeviceDebugSupport::handleAppRunnerFinished(bool success) { - if (!d->runControl || state() == Inactive) + if (state() == Inactive) return; if (state() == Running) { // The QML engine does not realize on its own that the application has finished. if (d->qmlDebugging && !d->cppDebugging) - d->runControl->quitDebugger(); + runControl()->quitDebugger(); else if (!success) - d->runControl->notifyInferiorIll(); + runControl()->notifyInferiorIll(); } else if (state() == StartingRunner) { RemoteSetupResult result; result.success = false; result.reason = tr("Debugging failed."); - d->runControl->notifyEngineRemoteSetupFinished(result); + runControl()->notifyEngineRemoteSetupFinished(result); } reset(); } @@ -228,9 +229,6 @@ void LinuxDeviceDebugSupport::handleRemoteErrorOutput(const QByteArray &output) { QTC_ASSERT(state() != GatheringResources, return); - if (!d->runControl) - return; - showMessage(QString::fromUtf8(output), AppError); if (state() == StartingRunner && d->cppDebugging) { d->gdbserverOutput += output; @@ -253,7 +251,7 @@ void LinuxDeviceDebugSupport::handleAdapterSetupFailed(const QString &error) RemoteSetupResult result; result.success = false; result.reason = tr("Initial setup failed: %1").arg(error); - d->runControl->notifyEngineRemoteSetupFinished(result); + runControl()->notifyEngineRemoteSetupFinished(result); } void LinuxDeviceDebugSupport::handleAdapterSetupDone() @@ -264,7 +262,7 @@ void LinuxDeviceDebugSupport::handleAdapterSetupDone() result.success = true; result.gdbServerPort = d->gdbServerPort; result.qmlServerPort = d->qmlPort; - d->runControl->notifyEngineRemoteSetupFinished(result); + runControl()->notifyEngineRemoteSetupFinished(result); } void LinuxDeviceDebugSupport::handleRemoteProcessStarted() diff --git a/src/plugins/remotelinux/remotelinuxdebugsupport.h b/src/plugins/remotelinux/remotelinuxdebugsupport.h index 33e130ba2b8..c4b777288a2 100644 --- a/src/plugins/remotelinux/remotelinuxdebugsupport.h +++ b/src/plugins/remotelinux/remotelinuxdebugsupport.h @@ -38,8 +38,7 @@ class REMOTELINUX_EXPORT LinuxDeviceDebugSupport : public AbstractRemoteLinuxRun Q_OBJECT public: - LinuxDeviceDebugSupport(ProjectExplorer::RunConfiguration *runConfig, - Debugger::DebuggerRunControl *runControl); + LinuxDeviceDebugSupport(ProjectExplorer::RunControl *runControl); ~LinuxDeviceDebugSupport() override; protected: @@ -63,6 +62,7 @@ private: void handleDebuggingFinished(); void showMessage(const QString &msg, int channel); + Debugger::DebuggerRunControl *runControl() const; Internal::LinuxDeviceDebugSupportPrivate * const d; }; diff --git a/src/plugins/remotelinux/remotelinuxruncontrolfactory.cpp b/src/plugins/remotelinux/remotelinuxruncontrolfactory.cpp index b7e371f29ab..f18284a5a57 100644 --- a/src/plugins/remotelinux/remotelinuxruncontrolfactory.cpp +++ b/src/plugins/remotelinux/remotelinuxruncontrolfactory.cpp @@ -138,7 +138,7 @@ RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, Co DebuggerRunControl * const runControl = createDebuggerRunControl(params, runConfig, errorMessage, mode); if (!runControl) return 0; - (void) new LinuxDeviceDebugSupport(runConfig, runControl); + (void) new LinuxDeviceDebugSupport(runControl); return runControl; } @@ -150,7 +150,7 @@ RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, Co DeviceKitInformation::device(runConfig->target()->kit())->sshParameters(); connection.analyzerHost = connection.connParams.host; runControl->setConnection(connection); - (void) new RemoteLinuxAnalyzeSupport(runConfig, runControl, mode); + (void) new RemoteLinuxAnalyzeSupport(runControl, mode); return runControl; } |