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>
This commit is contained in:
Daniel Teske
2011-07-04 14:09:27 +02:00
parent 7d39539657
commit b778692510
6 changed files with 40 additions and 1 deletions

View File

@@ -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;
}

View File

@@ -84,6 +84,8 @@ public:
bool aboutToClose() const;
bool closeTabs(CloseTabMode mode);
QList<RunControl *> runControls() const;
signals:
void allRunControlsFinished();

View File

@@ -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)

View File

@@ -130,6 +130,8 @@ public:
void buildProject(ProjectExplorer::Project *p);
QList<RunControl *> runControls() const;
signals:
void aboutToShowContextMenu(ProjectExplorer::Project *project,
ProjectExplorer::Node *node);

View File

@@ -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);

View File

@@ -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 {