diff --git a/src/plugins/analyzerbase/analyzermanager.cpp b/src/plugins/analyzerbase/analyzermanager.cpp index 759dbd73062..c5e8fb2b2f2 100644 --- a/src/plugins/analyzerbase/analyzermanager.cpp +++ b/src/plugins/analyzerbase/analyzermanager.cpp @@ -719,4 +719,12 @@ AnalyzerRunControl *AnalyzerManager::createRunControl(RunConfiguration *runConfi return 0; } +bool operator==(const AnalyzerConnection &c1, const AnalyzerConnection &c2) +{ + return c1.connParams == c2.connParams + && c1.analyzerHost == c2.analyzerHost + && c1.analyzerSocket == c2.analyzerSocket + && c1.analyzerPort == c2.analyzerPort; +} + } // namespace Analyzer diff --git a/src/plugins/analyzerbase/analyzerstartparameters.h b/src/plugins/analyzerbase/analyzerstartparameters.h index 3f01f20b1bb..1b4a3a6bdff 100644 --- a/src/plugins/analyzerbase/analyzerstartparameters.h +++ b/src/plugins/analyzerbase/analyzerstartparameters.h @@ -44,6 +44,8 @@ public: quint16 analyzerPort = 0; }; +ANALYZER_EXPORT bool operator==(const AnalyzerConnection &c1, const AnalyzerConnection &c2); + } // namespace Analyzer #endif // ANALYZERSTARTPARAMETERS_H diff --git a/src/plugins/android/androidrunnable.h b/src/plugins/android/androidrunnable.h index 21d8897e235..453807c359e 100644 --- a/src/plugins/android/androidrunnable.h +++ b/src/plugins/android/androidrunnable.h @@ -42,6 +42,17 @@ struct ANDROID_EXPORT AndroidRunnable QString deviceSerialNumber; }; +inline bool operator==(const AndroidRunnable &r1, const AndroidRunnable &r2) +{ + return r1.packageName == r2.packageName + && r1.intentName == r2.intentName + && r1.commandLineArguments == r2.commandLineArguments + && r1.environment == r2.environment + && r1.beforeStartADBCommands == r2.beforeStartADBCommands + && r1.afterFinishADBCommands == r2.afterFinishADBCommands + && r1.deviceSerialNumber == r2.deviceSerialNumber; +} + } // namespace Android #endif // ANDROIDRUNNABLE_H diff --git a/src/plugins/projectexplorer/appoutputpane.cpp b/src/plugins/projectexplorer/appoutputpane.cpp index 3d1319c5592..0ca23e9e7d6 100644 --- a/src/plugins/projectexplorer/appoutputpane.cpp +++ b/src/plugins/projectexplorer/appoutputpane.cpp @@ -398,7 +398,7 @@ void AppOutputPane::createNewOutputWindow(RunControl *rc) const int size = m_runControlTabs.size(); for (int i = 0; i < size; i++) { RunControlTab &tab =m_runControlTabs[i]; - if (tab.runControl->sameRunConfiguration(rc) && !tab.runControl->isRunning()) { + if (rc->canReUseOutputPane(tab.runControl)) { // Reuse this tab delete tab.runControl; tab.runControl = rc; diff --git a/src/plugins/projectexplorer/projectexplorer.pro b/src/plugins/projectexplorer/projectexplorer.pro index 380070855a9..c544a9ddead 100644 --- a/src/plugins/projectexplorer/projectexplorer.pro +++ b/src/plugins/projectexplorer/projectexplorer.pro @@ -168,6 +168,7 @@ SOURCES += projectexplorer.cpp \ environmentaspectwidget.cpp \ gcctoolchain.cpp \ importwidget.cpp \ + runnables.cpp \ localenvironmentaspect.cpp \ osparser.cpp \ projectimporter.cpp \ diff --git a/src/plugins/projectexplorer/projectexplorer.qbs b/src/plugins/projectexplorer/projectexplorer.qbs index 530b3a0982f..5dff962409d 100644 --- a/src/plugins/projectexplorer/projectexplorer.qbs +++ b/src/plugins/projectexplorer/projectexplorer.qbs @@ -127,7 +127,7 @@ QtcPlugin { "projectwizardpage.cpp", "projectwizardpage.h", "projectwizardpage.ui", "propertiespanel.cpp", "propertiespanel.h", "removetaskhandler.cpp", "removetaskhandler.h", - "runnables.h", + "runnables.cpp", "runnables.h", "runconfiguration.cpp", "runconfiguration.h", "runconfigurationaspects.cpp", "runconfigurationaspects.h", "runconfigurationmodel.cpp", "runconfigurationmodel.h", diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 3a7156eb5f5..2cac36dc12d 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -655,6 +655,14 @@ Project *RunControl::project() const return d->project.data(); } +bool RunControl::canReUseOutputPane(const RunControl *other) const +{ + if (other->isRunning()) + return false; + + return d->runnable == other->d->runnable; +} + ProcessHandle RunControl::applicationProcessHandle() const { return d->applicationProcessHandle; @@ -723,11 +731,6 @@ bool RunControl::showPromptToStopDialog(const QString &title, return close; } -bool RunControl::sameRunConfiguration(const RunControl *other) const -{ - return other->d->runConfiguration.data() == d->runConfiguration.data(); -} - void RunControl::bringApplicationToForeground(qint64 pid) { #ifdef Q_OS_OSX @@ -760,4 +763,9 @@ void RunControl::appendMessage(const QString &msg, Utils::OutputFormat format) emit appendMessage(this, msg, format); } +bool Runnable::operator==(const Runnable &other) const +{ + return d ? d->equals(other.d) : (other.d.get() == 0); +} + } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index b16a159d5e5..839e45c79cb 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -158,6 +158,7 @@ class PROJECTEXPLORER_EXPORT ClonableConcept public: virtual ~ClonableConcept() {} virtual ClonableConcept *clone() const = 0; + virtual bool equals(const std::unique_ptr &other) const = 0; }; template @@ -167,6 +168,12 @@ public: ClonableModel(const T &data) : m_data(data) {} ClonableConcept *clone() const override { return new ClonableModel(*this); } + bool equals(const std::unique_ptr &other) const override + { + auto that = dynamic_cast *>(other.get()); + return that && m_data == that->m_data; + } + T m_data; }; @@ -188,6 +195,8 @@ public: return static_cast *>(d.get())->m_data; } + bool operator==(const Runnable &other) const; + private: std::unique_ptr d; }; @@ -363,7 +372,7 @@ public: RunConfiguration *runConfiguration() const; Project *project() const; - bool sameRunConfiguration(const RunControl *other) const; + bool canReUseOutputPane(const RunControl *other) const; Utils::OutputFormatter *outputFormatter(); Core::Id runMode() const; diff --git a/src/plugins/projectexplorer/runnables.cpp b/src/plugins/projectexplorer/runnables.cpp new file mode 100644 index 00000000000..c05b0a4c12e --- /dev/null +++ b/src/plugins/projectexplorer/runnables.cpp @@ -0,0 +1,38 @@ +/**************************************************************************** +** +** 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; +} + +} // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/runnables.h b/src/plugins/projectexplorer/runnables.h index 12eef7595b6..41079482ebb 100644 --- a/src/plugins/projectexplorer/runnables.h +++ b/src/plugins/projectexplorer/runnables.h @@ -45,6 +45,8 @@ public: ApplicationLauncher::Mode runMode; }; +PROJECTEXPLORER_EXPORT bool operator==(const StandardRunnable &r1, const StandardRunnable &r2); + } // namespace ProjectExplorer #endif // PROJECTEXPLORER_RUNNABLES_H