diff options
author | Daniel Teske <daniel.teske@nokia.com> | 2011-07-04 14:09:27 +0200 |
---|---|---|
committer | Daniel Teske <daniel.teske@nokia.com> | 2011-07-19 18:53:15 +0200 |
commit | b7786925109fb99a291c0b71083b3ae711b44427 (patch) | |
tree | 4d2798e9a32b61a74800d9ec9719ee4348c0778a /src/plugins/qmlprojectmanager | |
parent | 7d39539657ead227223f071cdf1bd2306eee137f (diff) | |
download | qt-creator-b7786925109fb99a291c0b71083b3ae711b44427.tar.gz |
Qml run controls automatically stop all run controls for the same file
That's something which has been asked for multiple times. Also related
to the task below.
Change-Id: I1130a2a3527479f18bde2abfbff28fb556f437b9
Task-Nr: QTCREATORBUG-3508
Reviewed-on: http://codereview.qt.nokia.com/1844
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
Diffstat (limited to 'src/plugins/qmlprojectmanager')
-rw-r--r-- | src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp | 20 | ||||
-rw-r--r-- | src/plugins/qmlprojectmanager/qmlprojectruncontrol.h | 3 |
2 files changed, 22 insertions, 1 deletions
diff --git a/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp b/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp index 205b748128..78dde994f8 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectruncontrol.cpp @@ -36,6 +36,7 @@ #include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/target.h> #include <projectexplorer/project.h> +#include <projectexplorer/projectexplorer.h> #include <utils/qtcassert.h> #include <debugger/debuggerrunner.h> @@ -67,6 +68,7 @@ QmlProjectRunControl::QmlProjectRunControl(QmlProjectRunConfiguration *runConfig m_executable = runConfiguration->observerPath(); } m_commandLineArguments = runConfiguration->viewerArguments(); + m_mainQmlFile = runConfiguration->mainScript(); connect(&m_applicationLauncher, SIGNAL(appendMessage(QString,Utils::OutputFormat)), this, SLOT(slotAppendMessage(QString, Utils::OutputFormat))); @@ -126,6 +128,11 @@ void QmlProjectRunControl::processExited(int exitCode) emit finished(); } +QString QmlProjectRunControl::mainQmlFile() const +{ + return m_mainQmlFile; +} + QmlProjectRunControlFactory::QmlProjectRunControlFactory(QObject *parent) : IRunControlFactory(parent) { @@ -163,8 +170,19 @@ RunControl *QmlProjectRunControlFactory::create(RunConfiguration *runConfigurati const QString &mode) { QTC_ASSERT(canRun(runConfiguration, mode), return 0); - QmlProjectRunConfiguration *config = qobject_cast<QmlProjectRunConfiguration *>(runConfiguration); + + QList<ProjectExplorer::RunControl *> runcontrols = + ProjectExplorer::ProjectExplorerPlugin::instance()->runControls(); + foreach (ProjectExplorer::RunControl *rc, runcontrols) { + if (QmlProjectRunControl *qrc = qobject_cast<QmlProjectRunControl *>(rc)) { + if (qrc->mainQmlFile() == config->mainScript()) + // Asking the user defeats the purpose + // Making it configureable might be worth it + qrc->stop(); + } + } + RunControl *runControl = 0; if (mode == ProjectExplorer::Constants::RUNMODE) runControl = new QmlProjectRunControl(config, mode); diff --git a/src/plugins/qmlprojectmanager/qmlprojectruncontrol.h b/src/plugins/qmlprojectmanager/qmlprojectruncontrol.h index 02a22c9728..62f5b82249 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectruncontrol.h +++ b/src/plugins/qmlprojectmanager/qmlprojectruncontrol.h @@ -55,6 +55,8 @@ public: virtual bool isRunning() const; virtual QIcon icon() const; + QString mainQmlFile() const; + private slots: void processExited(int exitCode); void slotBringApplicationToForeground(qint64 pid); @@ -65,6 +67,7 @@ private: QString m_executable; QString m_commandLineArguments; + QString m_mainQmlFile; }; class QmlProjectRunControlFactory : public ProjectExplorer::IRunControlFactory { |