Commit b7786925 authored by Daniel Teske's avatar Daniel Teske
Browse files

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: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarKai Koehne <kai.koehne@nokia.com>
parent 7d395396
......@@ -536,3 +536,12 @@ bool AppOutputPane::canNavigate()
{
return false;
}
QList<RunControl *> AppOutputPane::runControls() const
{
QList<RunControl *> result;
foreach (const RunControlTab& tab, m_runControlTabs)
result << tab.runControl;
return result;
}
......@@ -84,6 +84,8 @@ public:
bool aboutToClose() const;
bool closeTabs(CloseTabMode mode);
QList<RunControl *> runControls() const;
signals:
void allRunControlsFinished();
......
......@@ -1504,6 +1504,11 @@ void ProjectExplorerPlugin::startRunControl(RunControl *runControl, const QStrin
emit updateRunActions();
}
QList<RunControl *> ProjectExplorerPlugin::runControls() const
{
return d->m_outputPane->runControls();
}
void ProjectExplorerPlugin::buildQueueFinished(bool success)
{
if (debug)
......
......@@ -130,6 +130,8 @@ public:
void buildProject(ProjectExplorer::Project *p);
QList<RunControl *> runControls() const;
signals:
void aboutToShowContextMenu(ProjectExplorer::Project *project,
ProjectExplorer::Node *node);
......
......@@ -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);
......
......@@ -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 {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment