From eb0b0f944305918a3b94af12619f16199e5954b1 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 24 Mar 2017 17:06:13 +0100 Subject: [PATCH] ProjectExplorer: Create a ToolRunSupport base class This is meant to be a base for tool-specific additions to the target-specific RunControls providing a common base and convenience interface for the various *{Debug,Analyze,*}Support classes. Code in the current support classes in intended to be split in bits suitable to be handled by the target run controls and in target-independent bits in the pure tool implementation, making the ToolRunSupport derived instances as slim as possible. Change-Id: I2bc3f4ad246f6ea81b19458ee5a4392609e4fd2d Reviewed-by: Tobias Hunger --- .../projectexplorer/runconfiguration.cpp | 29 +++++++++++++++++-- .../projectexplorer/runconfiguration.h | 19 ++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index f78b5fd720b..409bac15a9d 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -519,6 +519,7 @@ public: ~RunControlPrivate() { + delete toolRunner; delete outputFormatter; } @@ -528,8 +529,9 @@ public: Connection connection; Core::Id runMode; Utils::Icon icon; - const QPointer runConfiguration; - QPointer project; + const QPointer runConfiguration; // Not owned. + QPointer project; // Not owned. + QPointer toolRunner; // Owned. QPointer as "extra safety" for now. Utils::OutputFormatter *outputFormatter = nullptr; // A handle to the actual application process. @@ -617,6 +619,16 @@ void RunControl::setConnection(const Connection &connection) d->connection = connection; } +ToolRunner *RunControl::toolRunner() const +{ + return d->toolRunner; +} + +void RunControl::setToolRunner(ToolRunner *tool) +{ + d->toolRunner = tool; +} + QString RunControl::displayName() const { return d->displayName; @@ -964,4 +976,17 @@ void SimpleRunControl::onProcessFinished(int exitCode, QProcess::ExitStatus stat reportApplicationStop(); } +// ToolRunner + +ToolRunner::ToolRunner(RunControl *runControl) + : m_runControl(runControl) +{ + runControl->setToolRunner(this); +} + +RunControl *ToolRunner::runControl() const +{ + return m_runControl; +} + } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index 0121374c4a3..9fb582b20d7 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -49,6 +49,7 @@ class IRunConfigurationAspect; class RunConfiguration; class RunConfigWidget; class RunControl; +class ToolRunner; class Target; namespace Internal { @@ -397,6 +398,9 @@ public: const Connection &connection() const; void setConnection(const Connection &connection); + ToolRunner *toolRunner() const; + void setToolRunner(ToolRunner *tool); + virtual void appendMessage(const QString &msg, Utils::OutputFormat format); virtual void bringApplicationToForeground(); @@ -444,4 +448,19 @@ private: Internal::SimpleRunControlPrivate * const d; }; +/** + * A base for tool-specific additions to target-specific RunControl. + */ + +class PROJECTEXPLORER_EXPORT ToolRunner : public QObject +{ +public: + explicit ToolRunner(RunControl *runControl); + + RunControl *runControl() const; + +private: + QPointer m_runControl; +}; + } // namespace ProjectExplorer