Commit 2182ded5 authored by BogDan Vatra's avatar BogDan Vatra

ProjectExplorer: Use Core::Id as RunMode "enum values"

This provides a way for third-party plugins to implement run
modes without the need to add a value to the central enum or
using manual workarounds like RunMode(*(int*)&someUniqueObject).

Instead of centrally defined enum values this uses Core::Id that could
be defined anywhere.

Change-Id: Ic350e3d8dbb8042c61b2d4ffec993ca151f53099
Reviewed-by: default avatarDaniel Teske <daniel.teske@theqtcompany.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 77436649
...@@ -36,10 +36,11 @@ ...@@ -36,10 +36,11 @@
#include <QMetaType> #include <QMetaType>
#include <coreplugin/id.h>
#include <ssh/sshconnection.h> #include <ssh/sshconnection.h>
#include <utils/environment.h> #include <utils/environment.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/applicationlauncher.h> #include <projectexplorer/applicationlauncher.h>
#include <projectexplorer/projectexplorerconstants.h>
namespace Analyzer { namespace Analyzer {
...@@ -49,7 +50,7 @@ namespace Analyzer { ...@@ -49,7 +50,7 @@ namespace Analyzer {
class ANALYZER_EXPORT AnalyzerStartParameters class ANALYZER_EXPORT AnalyzerStartParameters
{ {
public: public:
ProjectExplorer::RunMode runMode; Core::Id runMode = ProjectExplorer::Constants::NO_RUN_MODE;
QSsh::SshConnectionParameters connParams; QSsh::SshConnectionParameters connParams;
ProjectExplorer::ApplicationLauncher::Mode localRunMode ProjectExplorer::ApplicationLauncher::Mode localRunMode
= ProjectExplorer::ApplicationLauncher::Gui; = ProjectExplorer::ApplicationLauncher::Gui;
......
...@@ -86,8 +86,8 @@ public: ...@@ -86,8 +86,8 @@ public:
void setToolId(Core::Id id) { m_toolId = id; } void setToolId(Core::Id id) { m_toolId = id; }
void setToolMode(ToolMode mode) { m_toolMode = mode; } void setToolMode(ToolMode mode) { m_toolMode = mode; }
ProjectExplorer::RunMode runMode() const { return m_runMode; } Core::Id runMode() const { return m_runMode; }
void setRunMode(ProjectExplorer::RunMode mode) { m_runMode = mode; } void setRunMode(Core::Id mode) { m_runMode = mode; }
bool isRunnable(QString *reason = 0) const; bool isRunnable(QString *reason = 0) const;
/// Creates all widgets used by the tool. /// Creates all widgets used by the tool.
...@@ -119,7 +119,7 @@ protected: ...@@ -119,7 +119,7 @@ protected:
Core::Id m_actionId; Core::Id m_actionId;
Core::Id m_toolId; Core::Id m_toolId;
ToolMode m_toolMode; ToolMode m_toolMode;
ProjectExplorer::RunMode m_runMode; Core::Id m_runMode;
WidgetCreator m_widgetCreator; WidgetCreator m_widgetCreator;
RunControlCreator m_runControlCreator; RunControlCreator m_runControlCreator;
ToolStarter m_customToolStarter; ToolStarter m_customToolStarter;
......
...@@ -52,7 +52,7 @@ namespace Android { ...@@ -52,7 +52,7 @@ namespace Android {
namespace Internal { namespace Internal {
RunControl *AndroidAnalyzeSupport::createAnalyzeRunControl(AndroidRunConfiguration *runConfig, RunControl *AndroidAnalyzeSupport::createAnalyzeRunControl(AndroidRunConfiguration *runConfig,
RunMode runMode) Core::Id runMode)
{ {
Target *target = runConfig->target(); Target *target = runConfig->target();
AnalyzerStartParameters params; AnalyzerStartParameters params;
...@@ -61,7 +61,7 @@ RunControl *AndroidAnalyzeSupport::createAnalyzeRunControl(AndroidRunConfigurati ...@@ -61,7 +61,7 @@ RunControl *AndroidAnalyzeSupport::createAnalyzeRunControl(AndroidRunConfigurati
params.sysroot = SysRootKitInformation::sysRoot(target->kit()).toString(); params.sysroot = SysRootKitInformation::sysRoot(target->kit()).toString();
// TODO: Not sure if these are the right paths. // TODO: Not sure if these are the right paths.
params.workingDirectory = target->project()->projectDirectory().toString(); params.workingDirectory = target->project()->projectDirectory().toString();
if (runMode == QmlProfilerRunMode) { if (runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) {
QTcpServer server; QTcpServer server;
QTC_ASSERT(server.listen(QHostAddress::LocalHost) QTC_ASSERT(server.listen(QHostAddress::LocalHost)
|| server.listen(QHostAddress::LocalHostIPv6), return 0); || server.listen(QHostAddress::LocalHostIPv6), return 0);
......
...@@ -51,7 +51,7 @@ public: ...@@ -51,7 +51,7 @@ public:
Analyzer::AnalyzerRunControl *runControl); Analyzer::AnalyzerRunControl *runControl);
static ProjectExplorer::RunControl *createAnalyzeRunControl(AndroidRunConfiguration *runConfig, static ProjectExplorer::RunControl *createAnalyzeRunControl(AndroidRunConfiguration *runConfig,
ProjectExplorer::RunMode runMode); Core::Id runMode);
private: private:
QmlDebug::QmlOutputParser m_outputParser; QmlDebug::QmlOutputParser m_outputParser;
......
...@@ -42,8 +42,8 @@ namespace Android { ...@@ -42,8 +42,8 @@ namespace Android {
namespace Internal { namespace Internal {
AndroidRunControl::AndroidRunControl(AndroidRunConfiguration *rc) AndroidRunControl::AndroidRunControl(AndroidRunConfiguration *rc)
: RunControl(rc, NormalRunMode) : RunControl(rc, ProjectExplorer::Constants::NORMAL_RUN_MODE)
, m_runner(new AndroidRunner(this, rc, NormalRunMode)) , m_runner(new AndroidRunner(this, rc, ProjectExplorer::Constants::NORMAL_RUN_MODE))
, m_running(false) , m_running(false)
{ {
setIcon(QLatin1String(ProjectExplorer::Constants::ICON_RUN_SMALL)); setIcon(QLatin1String(ProjectExplorer::Constants::ICON_RUN_SMALL));
......
...@@ -56,35 +56,30 @@ AndroidRunControlFactory::AndroidRunControlFactory(QObject *parent) ...@@ -56,35 +56,30 @@ AndroidRunControlFactory::AndroidRunControlFactory(QObject *parent)
{ {
} }
bool AndroidRunControlFactory::canRun(RunConfiguration *runConfiguration, RunMode mode) const bool AndroidRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id mode) const
{ {
if (mode != NormalRunMode && mode != DebugRunMode && mode != QmlProfilerRunMode) if (mode != ProjectExplorer::Constants::NORMAL_RUN_MODE
&& mode != ProjectExplorer::Constants::DEBUG_RUN_MODE
&& mode != ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN
&& mode != ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) {
return false; return false;
}
return qobject_cast<AndroidRunConfiguration *>(runConfiguration); return qobject_cast<AndroidRunConfiguration *>(runConfiguration);
} }
RunControl *AndroidRunControlFactory::create(RunConfiguration *runConfig, RunControl *AndroidRunControlFactory::create(RunConfiguration *runConfig,
RunMode mode, QString *errorMessage) Core::Id mode, QString *errorMessage)
{ {
Q_ASSERT(canRun(runConfig, mode)); Q_ASSERT(canRun(runConfig, mode));
AndroidRunConfiguration *rc = qobject_cast<AndroidRunConfiguration *>(runConfig); AndroidRunConfiguration *rc = qobject_cast<AndroidRunConfiguration *>(runConfig);
Q_ASSERT(rc); Q_ASSERT(rc);
switch (mode) { if (mode == ProjectExplorer::Constants::NORMAL_RUN_MODE)
case NormalRunMode:
return new AndroidRunControl(rc); return new AndroidRunControl(rc);
case DebugRunMode: if (mode == ProjectExplorer::Constants::DEBUG_RUN_MODE || mode == ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN)
return AndroidDebugSupport::createDebugRunControl(rc, errorMessage); return AndroidDebugSupport::createDebugRunControl(rc, errorMessage);
case QmlProfilerRunMode: if (mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE)
return AndroidAnalyzeSupport::createAnalyzeRunControl(rc, mode); return AndroidAnalyzeSupport::createAnalyzeRunControl(rc, mode);
case NoRunMode: QTC_CHECK(false); // The other run modes are not supported
case DebugRunModeWithBreakOnMain:
case CallgrindRunMode:
case MemcheckRunMode:
case MemcheckWithGdbRunMode:
case ClangStaticAnalyzerMode:
case PerfProfilerRunMode:
QTC_CHECK(false); // The other run modes are not supported
}
return 0; return 0;
} }
......
...@@ -53,9 +53,9 @@ public: ...@@ -53,9 +53,9 @@ public:
explicit AndroidRunControlFactory(QObject *parent = 0); explicit AndroidRunControlFactory(QObject *parent = 0);
bool canRun(ProjectExplorer::RunConfiguration *runConfiguration, bool canRun(ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode) const; Core::Id mode) const;
ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration, ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode, Core::Id mode,
QString *errorMessage); QString *errorMessage);
}; };
......
...@@ -125,21 +125,21 @@ static int socketHandShakePort = MIN_SOCKET_HANDSHAKE_PORT; ...@@ -125,21 +125,21 @@ static int socketHandShakePort = MIN_SOCKET_HANDSHAKE_PORT;
AndroidRunner::AndroidRunner(QObject *parent, AndroidRunner::AndroidRunner(QObject *parent,
AndroidRunConfiguration *runConfig, AndroidRunConfiguration *runConfig,
ProjectExplorer::RunMode runMode) Core::Id runMode)
: QThread(parent), m_handShakeMethod(SocketHandShake), m_socket(0), : QThread(parent), m_handShakeMethod(SocketHandShake), m_socket(0),
m_customPort(false) m_customPort(false)
{ {
m_tries = 0; m_tries = 0;
Debugger::DebuggerRunConfigurationAspect *aspect Debugger::DebuggerRunConfigurationAspect *aspect
= runConfig->extraAspect<Debugger::DebuggerRunConfigurationAspect>(); = runConfig->extraAspect<Debugger::DebuggerRunConfigurationAspect>();
const bool debuggingMode = runMode == ProjectExplorer::DebugRunMode; const bool debuggingMode = (runMode == ProjectExplorer::Constants::DEBUG_RUN_MODE || runMode == ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN);
m_useCppDebugger = debuggingMode && aspect->useCppDebugger(); m_useCppDebugger = debuggingMode && aspect->useCppDebugger();
m_useQmlDebugger = debuggingMode && aspect->useQmlDebugger(); m_useQmlDebugger = debuggingMode && aspect->useQmlDebugger();
QString channel = runConfig->remoteChannel(); QString channel = runConfig->remoteChannel();
QTC_CHECK(channel.startsWith(QLatin1Char(':'))); QTC_CHECK(channel.startsWith(QLatin1Char(':')));
m_localGdbServerPort = channel.mid(1).toUShort(); m_localGdbServerPort = channel.mid(1).toUShort();
QTC_CHECK(m_localGdbServerPort); QTC_CHECK(m_localGdbServerPort);
m_useQmlProfiler = runMode == ProjectExplorer::QmlProfilerRunMode; m_useQmlProfiler = runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE;
if (m_useQmlDebugger || m_useQmlProfiler) { if (m_useQmlDebugger || m_useQmlProfiler) {
QTcpServer server; QTcpServer server;
QTC_ASSERT(server.listen(QHostAddress::LocalHost) QTC_ASSERT(server.listen(QHostAddress::LocalHost)
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include "androidconfigurations.h" #include "androidconfigurations.h"
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/runconfiguration.h>
#include <QObject> #include <QObject>
#include <QTimer> #include <QTimer>
...@@ -58,7 +58,7 @@ class AndroidRunner : public QThread ...@@ -58,7 +58,7 @@ class AndroidRunner : public QThread
public: public:
AndroidRunner(QObject *parent, AndroidRunConfiguration *runConfig, AndroidRunner(QObject *parent, AndroidRunConfiguration *runConfig,
ProjectExplorer::RunMode runMode); Core::Id runMode);
~AndroidRunner(); ~AndroidRunner();
QString displayName() const; QString displayName() const;
......
...@@ -71,17 +71,20 @@ BareMetalRunControlFactory::~BareMetalRunControlFactory() ...@@ -71,17 +71,20 @@ BareMetalRunControlFactory::~BareMetalRunControlFactory()
{ {
} }
bool BareMetalRunControlFactory::canRun(RunConfiguration *runConfiguration, RunMode mode) const bool BareMetalRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id mode) const
{ {
if (mode != NormalRunMode && mode != DebugRunMode && mode != DebugRunModeWithBreakOnMain) if (mode != ProjectExplorer::Constants::NORMAL_RUN_MODE
&& mode != ProjectExplorer::Constants::DEBUG_RUN_MODE
&& mode != ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN) {
return false; return false;
}
const QByteArray idStr = runConfiguration->id().name(); const QByteArray idStr = runConfiguration->id().name();
return runConfiguration->isEnabled() && idStr.startsWith(BareMetalRunConfiguration::IdPrefix); return runConfiguration->isEnabled() && idStr.startsWith(BareMetalRunConfiguration::IdPrefix);
} }
RunControl *BareMetalRunControlFactory::create( RunControl *BareMetalRunControlFactory::create(
RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage) RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage)
{ {
QTC_ASSERT(canRun(runConfiguration, mode), return 0); QTC_ASSERT(canRun(runConfiguration, mode), return 0);
......
...@@ -47,9 +47,9 @@ class BareMetalRunControlFactory : public ProjectExplorer::IRunControlFactory ...@@ -47,9 +47,9 @@ class BareMetalRunControlFactory : public ProjectExplorer::IRunControlFactory
public: public:
explicit BareMetalRunControlFactory(QObject *parent = 0); explicit BareMetalRunControlFactory(QObject *parent = 0);
~BareMetalRunControlFactory(); ~BareMetalRunControlFactory();
bool canRun(ProjectExplorer::RunConfiguration *runConfiguration, ProjectExplorer::RunMode mode) const; bool canRun(ProjectExplorer::RunConfiguration *runConfiguration, Core::Id mode) const;
ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration, ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode, Core::Id mode,
QString *errorMessage); QString *errorMessage);
}; };
......
...@@ -810,7 +810,7 @@ public slots: ...@@ -810,7 +810,7 @@ public slots:
void handleExecStep() void handleExecStep()
{ {
if (currentEngine()->state() == DebuggerNotReady) { if (currentEngine()->state() == DebuggerNotReady) {
ProjectExplorerPlugin::runStartupProject(DebugRunModeWithBreakOnMain); ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN);
} else { } else {
currentEngine()->resetLocation(); currentEngine()->resetLocation();
if (boolSetting(OperateByInstruction)) if (boolSetting(OperateByInstruction))
...@@ -823,7 +823,7 @@ public slots: ...@@ -823,7 +823,7 @@ public slots:
void handleExecNext() void handleExecNext()
{ {
if (currentEngine()->state() == DebuggerNotReady) { if (currentEngine()->state() == DebuggerNotReady) {
ProjectExplorerPlugin::runStartupProject(DebugRunModeWithBreakOnMain); ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN);
} else { } else {
currentEngine()->resetLocation(); currentEngine()->resetLocation();
if (boolSetting(OperateByInstruction)) if (boolSetting(OperateByInstruction))
...@@ -1306,7 +1306,7 @@ void DebuggerPluginPrivate::onCurrentProjectChanged(Project *project) ...@@ -1306,7 +1306,7 @@ void DebuggerPluginPrivate::onCurrentProjectChanged(Project *project)
m_continueAction->setEnabled(false); m_continueAction->setEnabled(false);
m_exitAction->setEnabled(false); m_exitAction->setEnabled(false);
QString whyNot; QString whyNot;
const bool canRun = ProjectExplorerPlugin::canRun(project, DebugRunMode, &whyNot); const bool canRun = ProjectExplorerPlugin::canRun(project, ProjectExplorer::Constants::DEBUG_RUN_MODE, &whyNot);
m_startAction->setEnabled(canRun); m_startAction->setEnabled(canRun);
m_startAction->setToolTip(whyNot); m_startAction->setToolTip(whyNot);
m_debugWithoutDeployAction->setEnabled(canRun); m_debugWithoutDeployAction->setEnabled(canRun);
...@@ -1978,7 +1978,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine) ...@@ -1978,7 +1978,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
m_localsAndExpressionsWindow->setShowLocals(false); m_localsAndExpressionsWindow->setShowLocals(false);
} else if (state == DebuggerFinished) { } else if (state == DebuggerFinished) {
Project *project = SessionManager::startupProject(); Project *project = SessionManager::startupProject();
const bool canRun = ProjectExplorerPlugin::canRun(project, DebugRunMode); const bool canRun = ProjectExplorerPlugin::canRun(project, ProjectExplorer::Constants::DEBUG_RUN_MODE);
// We don't want to do anything anymore. // We don't want to do anything anymore.
m_interruptAction->setEnabled(false); m_interruptAction->setEnabled(false);
m_continueAction->setEnabled(false); m_continueAction->setEnabled(false);
...@@ -2080,7 +2080,7 @@ void DebuggerPluginPrivate::updateDebugActions() ...@@ -2080,7 +2080,7 @@ void DebuggerPluginPrivate::updateDebugActions()
Project *project = SessionManager::startupProject(); Project *project = SessionManager::startupProject();
QString whyNot; QString whyNot;
const bool canRun = ProjectExplorerPlugin::canRun(project, DebugRunMode, &whyNot); const bool canRun = ProjectExplorerPlugin::canRun(project, ProjectExplorer::Constants::DEBUG_RUN_MODE, &whyNot);
m_startAction->setEnabled(canRun); m_startAction->setEnabled(canRun);
m_startAction->setToolTip(whyNot); m_startAction->setToolTip(whyNot);
m_debugWithoutDeployAction->setEnabled(canRun); m_debugWithoutDeployAction->setEnabled(canRun);
...@@ -2089,7 +2089,7 @@ void DebuggerPluginPrivate::updateDebugActions() ...@@ -2089,7 +2089,7 @@ void DebuggerPluginPrivate::updateDebugActions()
if (m_snapshotHandler->currentIndex() < 0) { if (m_snapshotHandler->currentIndex() < 0) {
QString toolTip; QString toolTip;
const bool canRunAndBreakMain const bool canRunAndBreakMain
= ProjectExplorerPlugin::canRun(project, DebugRunModeWithBreakOnMain, &toolTip); = ProjectExplorerPlugin::canRun(project, ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN, &toolTip);
m_stepAction->setEnabled(canRunAndBreakMain); m_stepAction->setEnabled(canRunAndBreakMain);
m_nextAction->setEnabled(canRunAndBreakMain); m_nextAction->setEnabled(canRunAndBreakMain);
if (canRunAndBreakMain) { if (canRunAndBreakMain) {
...@@ -2592,11 +2592,11 @@ void DebuggerPluginPrivate::extensionsInitialized() ...@@ -2592,11 +2592,11 @@ void DebuggerPluginPrivate::extensionsInitialized()
debuggerIcon.addFile(QLatin1String(":/projectexplorer/images/debugger_start.png")); debuggerIcon.addFile(QLatin1String(":/projectexplorer/images/debugger_start.png"));
act->setIcon(debuggerIcon); act->setIcon(debuggerIcon);
act->setText(tr("Start Debugging")); act->setText(tr("Start Debugging"));
connect(act, &QAction::triggered, [] { ProjectExplorerPlugin::runStartupProject(DebugRunMode); }); connect(act, &QAction::triggered, [] { ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE); });
act = m_debugWithoutDeployAction = new QAction(this); act = m_debugWithoutDeployAction = new QAction(this);
act->setText(tr("Start Debugging Without Deployment")); act->setText(tr("Start Debugging Without Deployment"));
connect(act, &QAction::triggered, [] { ProjectExplorerPlugin::runStartupProject(DebugRunMode, true); }); connect(act, &QAction::triggered, [] { ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE, true); });
act = m_startAndDebugApplicationAction = new QAction(this); act = m_startAndDebugApplicationAction = new QAction(this);
act->setText(tr("Start and Debug External Application...")); act->setText(tr("Start and Debug External Application..."));
......
...@@ -70,6 +70,9 @@ namespace Debugger { ...@@ -70,6 +70,9 @@ namespace Debugger {
namespace Internal { namespace Internal {
DebuggerEngine *createCdbEngine(const DebuggerRunParameters &rp, QStringList *error); DebuggerEngine *createCdbEngine(const DebuggerRunParameters &rp, QStringList *error);
const auto *DebugRunMode = ProjectExplorer::Constants::DEBUG_RUN_MODE;
const auto *DebugRunModeWithBreakOnMain = ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN;
DebuggerEngine *createGdbEngine(const DebuggerRunParameters &rp); DebuggerEngine *createGdbEngine(const DebuggerRunParameters &rp);
DebuggerEngine *createPdbEngine(const DebuggerRunParameters &rp); DebuggerEngine *createPdbEngine(const DebuggerRunParameters &rp);
DebuggerEngine *createQmlEngine(const DebuggerRunParameters &rp); DebuggerEngine *createQmlEngine(const DebuggerRunParameters &rp);
...@@ -295,7 +298,7 @@ public: ...@@ -295,7 +298,7 @@ public:
// detectable pieces, construct an Engine and a RunControl. // detectable pieces, construct an Engine and a RunControl.
void initialize(const DebuggerStartParameters &sp); void initialize(const DebuggerStartParameters &sp);
void enrich(const RunConfiguration *runConfig, const Kit *kit); void enrich(const RunConfiguration *runConfig, const Kit *kit);
void createRunControl(RunMode runMode); void createRunControl(Core::Id runMode = DebugRunMode);
QString fullError() const { return m_errors.join(QLatin1Char('\n')); } QString fullError() const { return m_errors.join(QLatin1Char('\n')); }
// Result. // Result.
...@@ -536,7 +539,7 @@ DebuggerEngine *createEngine(DebuggerEngineType et, const DebuggerRunParameters ...@@ -536,7 +539,7 @@ DebuggerEngine *createEngine(DebuggerEngineType et, const DebuggerRunParameters
return 0; return 0;
} }
void DebuggerRunControlCreator::createRunControl(RunMode runMode) void DebuggerRunControlCreator::createRunControl(Core::Id runMode)
{ {
if (runMode == DebugRunModeWithBreakOnMain) if (runMode == DebugRunModeWithBreakOnMain)
m_rp.breakOnMain = true; m_rp.breakOnMain = true;
...@@ -569,7 +572,7 @@ public: ...@@ -569,7 +572,7 @@ public:
{} {}
RunControl *create(RunConfiguration *runConfig, RunControl *create(RunConfiguration *runConfig,
RunMode mode, QString *errorMessage) override Core::Id mode, QString *errorMessage) override
{ {
QTC_ASSERT(runConfig, return 0); QTC_ASSERT(runConfig, return 0);
QTC_ASSERT(mode == DebugRunMode || mode == DebugRunModeWithBreakOnMain, return 0); QTC_ASSERT(mode == DebugRunMode || mode == DebugRunModeWithBreakOnMain, return 0);
...@@ -584,7 +587,7 @@ public: ...@@ -584,7 +587,7 @@ public:
return creator.m_runControl; return creator.m_runControl;
} }
bool canRun(RunConfiguration *runConfig, RunMode mode) const override bool canRun(RunConfiguration *runConfig, Core::Id mode) const override
{ {
return (mode == DebugRunMode || mode == DebugRunModeWithBreakOnMain) return (mode == DebugRunMode || mode == DebugRunModeWithBreakOnMain)
&& qobject_cast<LocalApplicationRunConfiguration *>(runConfig); && qobject_cast<LocalApplicationRunConfiguration *>(runConfig);
...@@ -633,7 +636,7 @@ DebuggerRunControl *createAndScheduleRun(const DebuggerRunParameters &rp, const ...@@ -633,7 +636,7 @@ DebuggerRunControl *createAndScheduleRun(const DebuggerRunParameters &rp, const
DebuggerRunControl *createDebuggerRunControl(const DebuggerStartParameters &sp, DebuggerRunControl *createDebuggerRunControl(const DebuggerStartParameters &sp,
RunConfiguration *runConfig, RunConfiguration *runConfig,
QString *errorMessage, QString *errorMessage,
RunMode runMode) Core::Id runMode)
{ {
DebuggerRunControlCreator creator; DebuggerRunControlCreator creator;
creator.initialize(sp); creator.initialize(sp);
......
...@@ -50,7 +50,7 @@ class DebuggerRunControlCreator; ...@@ -50,7 +50,7 @@ class DebuggerRunControlCreator;
DEBUGGER_EXPORT DebuggerRunControl *createDebuggerRunControl(const DebuggerStartParameters &sp, DEBUGGER_EXPORT DebuggerRunControl *createDebuggerRunControl(const DebuggerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfig, ProjectExplorer::RunConfiguration *runConfig,
QString *errorMessage, QString *errorMessage,
ProjectExplorer::RunMode runMode = ProjectExplorer::DebugRunMode); Core::Id runMode = ProjectExplorer::Constants::DEBUG_RUN_MODE);
class DEBUGGER_EXPORT DebuggerRunControl class DEBUGGER_EXPORT DebuggerRunControl
: public ProjectExplorer::RunControl : public ProjectExplorer::RunControl
......
...@@ -84,7 +84,7 @@ RunControl *IosAnalyzeSupport::createAnalyzeRunControl(IosRunConfiguration *runC ...@@ -84,7 +84,7 @@ RunControl *IosAnalyzeSupport::createAnalyzeRunControl(IosRunConfiguration *runC
if (device.isNull()) if (device.isNull())
return 0; return 0;
AnalyzerStartParameters params; AnalyzerStartParameters params;
params.runMode = QmlProfilerRunMode; params.runMode = ProjectExplorer::Constants::QML_PROFILER_RUN_MODE;
params.sysroot = SysRootKitInformation::sysRoot(target->kit()).toString(); params.sysroot = SysRootKitInformation::sysRoot(target->kit()).toString();
params.debuggee = runConfig->localExecutable().toUserOutput(); params.debuggee = runConfig->localExecutable().toUserOutput();
params.debuggeeArgs = Utils::QtcProcess::joinArgs(runConfig->commandLineArguments()); params.debuggeeArgs = Utils::QtcProcess::joinArgs(runConfig->commandLineArguments());
......
...@@ -41,7 +41,7 @@ namespace Ios { ...@@ -41,7 +41,7 @@ namespace Ios {
namespace Internal { namespace Internal {
IosRunControl::IosRunControl(IosRunConfiguration *rc) IosRunControl::IosRunControl(IosRunConfiguration *rc)
: RunControl(rc, NormalRunMode) : RunControl(rc, ProjectExplorer::Constants::NORMAL_RUN_MODE)
, m_runner(new IosRunner(this, rc, false, false)) , m_runner(new IosRunner(this, rc, false, false))
, m_running(false) , m_running(false)
{ {
......
...@@ -159,16 +159,20 @@ IosRunControlFactory::IosRunControlFactory(QObject *parent) ...@@ -159,16 +159,20 @@ IosRunControlFactory::IosRunControlFactory(QObject *parent)
} }
bool IosRunControlFactory::canRun(RunConfiguration *runConfiguration, bool IosRunControlFactory::canRun(RunConfiguration *runConfiguration,
RunMode mode) const Core::Id mode) const
{ {
if (mode != NormalRunMode && mode != DebugRunMode && mode != QmlProfilerRunMode if (mode != ProjectExplorer::Constants::NORMAL_RUN_MODE
&& mode != DebugRunModeWithBreakOnMain) && mode != ProjectExplorer::Constants::DEBUG_RUN_MODE
&& mode != ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN
&& mode != ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) {
return false; return false;
}
return qobject_cast<IosRunConfiguration *>(runConfiguration); return qobject_cast<IosRunConfiguration *>(runConfiguration);
} }
RunControl *IosRunControlFactory::create(RunConfiguration *runConfig, RunControl *IosRunControlFactory::create(RunConfiguration *runConfig,
RunMode mode, QString *errorMessage) Core::Id mode, QString *errorMessage)
{ {
Q_ASSERT(canRun(runConfig, mode)); Q_ASSERT(canRun(runConfig, mode));
IosRunConfiguration *rc = qobject_cast<IosRunConfiguration *>(runConfig); IosRunConfiguration *rc = qobject_cast<IosRunConfiguration *>(runConfig);
...@@ -181,9 +185,9 @@ RunControl *IosRunControlFactory::create(RunConfiguration *runConfig, ...@@ -181,9 +185,9 @@ RunControl *IosRunControlFactory::create(RunConfiguration *runConfig,
activeRunControl->stop(); activeRunControl->stop();
m_activeRunControls.remove(devId); m_activeRunControls.remove(devId);
} }
if (mode == NormalRunMode) if (mode == ProjectExplorer::Constants::NORMAL_RUN_MODE)
res = new Ios::Internal::IosRunControl(rc); res = new Ios::Internal::IosRunControl(rc);
else if (mode == QmlProfilerRunMode) else if (mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE)
res = IosAnalyzeSupport::createAnalyzeRunControl(rc, errorMessage); res = IosAnalyzeSupport::createAnalyzeRunControl(rc, errorMessage);
else else
res = IosDebugSupport::createDebugRunControl(rc, errorMessage); res = IosDebugSupport::createDebugRunControl(rc, errorMessage);
......
...@@ -81,9 +81,9 @@ public: ...@@ -81,9 +81,9 @@ public:
explicit IosRunControlFactory(QObject *parent = 0); explicit IosRunControlFactory(QObject *parent = 0);
bool canRun(ProjectExplorer::RunConfiguration *runConfiguration, bool canRun(ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode) const override; Core::Id mode) const override;
ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration, ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode, Core::Id mode,
QString *errorMessage) override; QString *errorMessage) override;
private: private:
mutable QMap<Core::Id, QPointer<ProjectExplorer::RunControl> > m_activeRunControls; mutable QMap<Core::Id, QPointer<ProjectExplorer::RunControl> > m_activeRunControls;
......
...@@ -48,12 +48,12 @@ LocalApplicationRunControlFactory::~LocalApplicationRunControlFactory() ...@@ -48,12 +48,12 @@ LocalApplicationRunControlFactory::~LocalApplicationRunControlFactory()
{ {
} }
bool LocalApplicationRunControlFactory::canRun(RunConfiguration *runConfiguration, RunMode mode) const bool LocalApplicationRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id mode) const
{ {
return mode == NormalRunMode && qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration); return mode == Constants::NORMAL_RUN_MODE && qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration);
} }
RunControl *LocalApplicationRunControlFactory::create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage) RunControl *LocalApplicationRunControlFactory::create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage)
{ {
Q_UNUSED(errorMessage) Q_UNUSED(errorMessage)
QTC_ASSERT(canRun(runConfiguration, mode), return 0); QTC_ASSERT(canRun(runConfiguration, mode), return 0);
...@@ -72,7 +72,7 @@ RunControl *LocalApplicationRunControlFactory::create(RunConfiguration *runConfi ...@@ -72,7 +72,7 @@ RunControl *LocalApplicationRunControlFactory::create(RunConfiguration *runConfi
// ApplicationRunControl // ApplicationRunControl
LocalApplicationRunControl::LocalApplicationRunControl(RunConfiguration *rc, RunMode mode) LocalApplicationRunControl::LocalApplicationRunControl(RunConfiguration *rc, Core::Id mode)
: RunControl(rc, mode), m_runMode(ApplicationLauncher::Console), m_running(false) : RunControl(rc, mode), m_runMode(ApplicationLauncher::Console), m_running(false)
{ {
setIcon(QLatin1String(Constants::ICON_RUN_SMALL)); setIcon(QLatin1String(Constants::ICON_RUN_SMALL));
......