diff --git a/src/plugins/debugger/analyzer/startremotedialog.cpp b/src/plugins/debugger/analyzer/startremotedialog.cpp index 76556f315df..810bbd4b5c1 100644 --- a/src/plugins/debugger/analyzer/startremotedialog.cpp +++ b/src/plugins/debugger/analyzer/startremotedialog.cpp @@ -128,7 +128,7 @@ void StartRemoteDialog::validate() d->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(valid); } -StandardRunnable StartRemoteDialog::runnable() const +Runnable StartRemoteDialog::runnable() const { Kit *kit = d->kitChooser->currentKit(); StandardRunnable r; diff --git a/src/plugins/debugger/analyzer/startremotedialog.h b/src/plugins/debugger/analyzer/startremotedialog.h index 028e512f8ba..b1b91bc62fd 100644 --- a/src/plugins/debugger/analyzer/startremotedialog.h +++ b/src/plugins/debugger/analyzer/startremotedialog.h @@ -29,7 +29,7 @@ #include -namespace ProjectExplorer { class StandardRunnable; } +namespace ProjectExplorer { class Runnable; } namespace Debugger { @@ -43,7 +43,7 @@ public: explicit StartRemoteDialog(QWidget *parent = nullptr); ~StartRemoteDialog() override; - ProjectExplorer::StandardRunnable runnable() const; + ProjectExplorer::Runnable runnable() const; private: void validate(); diff --git a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp index 10c452b027d..83ff88af383 100644 --- a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp +++ b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.cpp @@ -280,7 +280,7 @@ void SshDeviceProcess::handleKillOperationTimeout() emit finished(); } -QString SshDeviceProcess::fullCommandLine(const StandardRunnable &runnable) const +QString SshDeviceProcess::fullCommandLine(const Runnable &runnable) const { QString cmdLine = runnable.executable; if (!runnable.commandLineArguments.isEmpty()) diff --git a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.h b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.h index d97006e7f42..a6de321f3b5 100644 --- a/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.h +++ b/src/plugins/projectexplorer/devicesupport/sshdeviceprocess.h @@ -29,7 +29,7 @@ namespace ProjectExplorer { -class StandardRunnable; +class Runnable; class PROJECTEXPLORER_EXPORT SshDeviceProcess : public DeviceProcess { @@ -67,7 +67,7 @@ private: void handleKillOperationFinished(const QString &errorMessage); void handleKillOperationTimeout(); - virtual QString fullCommandLine(const StandardRunnable &runnable) const; + virtual QString fullCommandLine(const Runnable &runnable) const; virtual qint64 processId() const; class SshDeviceProcessPrivate; diff --git a/src/plugins/projectexplorer/projectexplorer.pro b/src/plugins/projectexplorer/projectexplorer.pro index 89c5401093c..b9a11dd39b4 100644 --- a/src/plugins/projectexplorer/projectexplorer.pro +++ b/src/plugins/projectexplorer/projectexplorer.pro @@ -164,7 +164,6 @@ SOURCES += projectexplorer.cpp \ gcctoolchain.cpp \ importwidget.cpp \ projectconfigurationmodel.cpp \ - runnables.cpp \ userfileaccessor.cpp \ localenvironmentaspect.cpp \ osparser.cpp \ diff --git a/src/plugins/projectexplorer/projectexplorer.qbs b/src/plugins/projectexplorer/projectexplorer.qbs index 05cda1d80af..ac5eaafcde5 100644 --- a/src/plugins/projectexplorer/projectexplorer.qbs +++ b/src/plugins/projectexplorer/projectexplorer.qbs @@ -119,7 +119,7 @@ Project { "projectwindow.cpp", "projectwindow.h", "projectwizardpage.cpp", "projectwizardpage.h", "projectwizardpage.ui", "removetaskhandler.cpp", "removetaskhandler.h", - "runnables.cpp", "runnables.h", + "runnables.h", "runconfiguration.cpp", "runconfiguration.h", "runconfigurationaspects.cpp", "runconfigurationaspects.h", "runsettingspropertiespage.cpp", "runsettingspropertiespage.h", diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index ffa3011d99f..2bb79ef79f5 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -1609,7 +1609,10 @@ void RunControl::appendMessage(const QString &msg, Utils::OutputFormat format) bool Runnable::canReUseOutputPane(const Runnable &other) const { - return d ? d->canReUseOutputPane(other.d) : (other.d.get() == 0); + return executable == other.executable + && commandLineArguments == other.commandLineArguments + && workingDirectory == other.workingDirectory + && environment == other.environment; } diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index a963f4fc807..d05086c3c08 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -31,6 +31,7 @@ #include "buildtargetinfo.h" #include "devicesupport/idevice.h" +#include #include #include #include @@ -157,60 +158,23 @@ private: class PROJECTEXPLORER_EXPORT Runnable { - struct Concept - { - virtual ~Concept() {} - virtual Concept *clone() const = 0; - virtual bool canReUseOutputPane(const std::unique_ptr &other) const = 0; - virtual QString displayName() const = 0; - virtual void *typeId() const = 0; - }; - - template - struct Model : public Concept - { - Model(const T &data) : m_data(data) {} - - Concept *clone() const override { return new Model(*this); } - - bool canReUseOutputPane(const std::unique_ptr &other) const override - { - if (!other.get()) - return false; - if (other->typeId() != typeId()) - return false; - auto that = static_cast *>(other.get()); - return m_data == that->m_data; - } - - QString displayName() const override { return m_data.displayName(); } - - void *typeId() const override { return T::staticTypeId; } - - T m_data; - }; - public: Runnable() = default; - Runnable(const Runnable &other) : d(other.d ? other.d->clone() : nullptr) { } - Runnable(Runnable &&other) : d(std::move(other.d)) {} - template Runnable(const T &data) : d(new Model(data)) {} - void operator=(Runnable other) { d = std::move(other.d); } - - template bool is() const { - return d.get() && (d.get()->typeId() == T::staticTypeId); - } - - template const T &as() const { - return static_cast *>(d.get())->m_data; - } + template bool is() const { return true; } + template const T &as() const { return *this; } bool canReUseOutputPane(const Runnable &other) const; - QString displayName() const { return d ? d->displayName() : QString(); } -private: - std::unique_ptr d; + QString executable; + QString commandLineArguments; + QString workingDirectory; + Utils::Environment environment; + ApplicationLauncher::Mode runMode = ApplicationLauncher::Gui; + IDevice::ConstPtr device; // Override the kit's device. Keep unset by default. + + // FIXME: Not necessarily a display name + QString displayName() const { return executable; } }; // Documentation inside. diff --git a/src/plugins/projectexplorer/runnables.cpp b/src/plugins/projectexplorer/runnables.cpp deleted file mode 100644 index a8c9be4aad2..00000000000 --- a/src/plugins/projectexplorer/runnables.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "runnables.h" - -namespace ProjectExplorer { - -bool operator==(const StandardRunnable &r1, const StandardRunnable &r2) -{ - return r1.executable == r2.executable - && r1.commandLineArguments == r2.commandLineArguments - && r1.workingDirectory == r2.workingDirectory - && r1.environment == r2.environment; -} - -void *StandardRunnable::staticTypeId = &StandardRunnable::staticTypeId; - -} // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/runnables.h b/src/plugins/projectexplorer/runnables.h index 91ac6c220ce..c0ee207ed5f 100644 --- a/src/plugins/projectexplorer/runnables.h +++ b/src/plugins/projectexplorer/runnables.h @@ -27,30 +27,8 @@ #include "runconfiguration.h" -#include "applicationlauncher.h" -#include "devicesupport/idevice.h" - -#include - - namespace ProjectExplorer { -class PROJECTEXPLORER_EXPORT StandardRunnable -{ -public: - QString executable; - QString commandLineArguments; - QString workingDirectory; - Utils::Environment environment; - ApplicationLauncher::Mode runMode = ApplicationLauncher::Gui; - IDevice::ConstPtr device; // Override the kit's device. Keep unset by default. - - // FIXME: Not necessarily a display name - QString displayName() const { return executable; } - - static void *staticTypeId; -}; - -PROJECTEXPLORER_EXPORT bool operator==(const StandardRunnable &r1, const StandardRunnable &r2); +using StandardRunnable = Runnable; } // namespace ProjectExplorer diff --git a/src/plugins/qnx/qnxdeviceprocess.cpp b/src/plugins/qnx/qnxdeviceprocess.cpp index 086e556e5d7..f96817946c6 100644 --- a/src/plugins/qnx/qnxdeviceprocess.cpp +++ b/src/plugins/qnx/qnxdeviceprocess.cpp @@ -43,7 +43,7 @@ QnxDeviceProcess::QnxDeviceProcess(const QSharedPointer &device, m_pidFile = QString::fromLatin1("/var/run/qtc.%1.pid").arg(++pidFileCounter); } -QString QnxDeviceProcess::fullCommandLine(const StandardRunnable &runnable) const +QString QnxDeviceProcess::fullCommandLine(const Runnable &runnable) const { QStringList args = QtcProcess::splitArgs(runnable.commandLineArguments); args.prepend(runnable.executable); diff --git a/src/plugins/qnx/qnxdeviceprocess.h b/src/plugins/qnx/qnxdeviceprocess.h index 6fbb6ac8ebd..d87146388ed 100644 --- a/src/plugins/qnx/qnxdeviceprocess.h +++ b/src/plugins/qnx/qnxdeviceprocess.h @@ -40,7 +40,7 @@ public: void interrupt() { doSignal(2); } void terminate() { doSignal(15); } void kill() { doSignal(9); } - QString fullCommandLine(const ProjectExplorer::StandardRunnable &runnable) const; + QString fullCommandLine(const ProjectExplorer::Runnable &runnable) const; private: void doSignal(int sig); diff --git a/src/plugins/remotelinux/linuxdeviceprocess.cpp b/src/plugins/remotelinux/linuxdeviceprocess.cpp index c3d56cad2b7..a58d404e105 100644 --- a/src/plugins/remotelinux/linuxdeviceprocess.cpp +++ b/src/plugins/remotelinux/linuxdeviceprocess.cpp @@ -73,7 +73,7 @@ qint64 LinuxDeviceProcess::processId() const return m_processId; } -QString LinuxDeviceProcess::fullCommandLine(const StandardRunnable &runnable) const +QString LinuxDeviceProcess::fullCommandLine(const Runnable &runnable) const { const Environment env = runnable.environment; diff --git a/src/plugins/remotelinux/linuxdeviceprocess.h b/src/plugins/remotelinux/linuxdeviceprocess.h index a37dd856865..4b565029cc8 100644 --- a/src/plugins/remotelinux/linuxdeviceprocess.h +++ b/src/plugins/remotelinux/linuxdeviceprocess.h @@ -46,7 +46,7 @@ public: QByteArray readAllStandardOutput() override; private: - QString fullCommandLine(const ProjectExplorer::StandardRunnable &) const override; + QString fullCommandLine(const ProjectExplorer::Runnable &) const override; qint64 processId() const override; QStringList rcFilesToSource() const;