diff options
author | BogDan Vatra <bogdan@kde.org> | 2015-06-29 10:36:29 +0300 |
---|---|---|
committer | BogDan Vatra <bogdan@kde.org> | 2015-06-30 06:20:54 +0000 |
commit | 2182ded57be0bd91ab4459e622c2ac8fbef90e65 (patch) | |
tree | 1b3941c056e883b5eaa8578b26f7bc26cbf2abe9 | |
parent | 7743664957f3a9e857d72530e475d13844bd4037 (diff) |
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: Daniel Teske <daniel.teske@theqtcompany.com>
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
50 files changed, 218 insertions, 219 deletions
diff --git a/src/plugins/analyzerbase/analyzerstartparameters.h b/src/plugins/analyzerbase/analyzerstartparameters.h index e03f2e92d2..3eab41f734 100644 --- a/src/plugins/analyzerbase/analyzerstartparameters.h +++ b/src/plugins/analyzerbase/analyzerstartparameters.h @@ -36,10 +36,11 @@ #include <QMetaType> +#include <coreplugin/id.h> #include <ssh/sshconnection.h> #include <utils/environment.h> -#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/applicationlauncher.h> +#include <projectexplorer/projectexplorerconstants.h> namespace Analyzer { @@ -49,7 +50,7 @@ namespace Analyzer { class ANALYZER_EXPORT AnalyzerStartParameters { public: - ProjectExplorer::RunMode runMode; + Core::Id runMode = ProjectExplorer::Constants::NO_RUN_MODE; QSsh::SshConnectionParameters connParams; ProjectExplorer::ApplicationLauncher::Mode localRunMode = ProjectExplorer::ApplicationLauncher::Gui; diff --git a/src/plugins/analyzerbase/ianalyzertool.h b/src/plugins/analyzerbase/ianalyzertool.h index b87414bffd..f7be88476f 100644 --- a/src/plugins/analyzerbase/ianalyzertool.h +++ b/src/plugins/analyzerbase/ianalyzertool.h @@ -86,8 +86,8 @@ public: void setToolId(Core::Id id) { m_toolId = id; } void setToolMode(ToolMode mode) { m_toolMode = mode; } - ProjectExplorer::RunMode runMode() const { return m_runMode; } - void setRunMode(ProjectExplorer::RunMode mode) { m_runMode = mode; } + Core::Id runMode() const { return m_runMode; } + void setRunMode(Core::Id mode) { m_runMode = mode; } bool isRunnable(QString *reason = 0) const; /// Creates all widgets used by the tool. @@ -119,7 +119,7 @@ protected: Core::Id m_actionId; Core::Id m_toolId; ToolMode m_toolMode; - ProjectExplorer::RunMode m_runMode; + Core::Id m_runMode; WidgetCreator m_widgetCreator; RunControlCreator m_runControlCreator; ToolStarter m_customToolStarter; diff --git a/src/plugins/android/androidanalyzesupport.cpp b/src/plugins/android/androidanalyzesupport.cpp index 6978424218..ff0dd9af9e 100644 --- a/src/plugins/android/androidanalyzesupport.cpp +++ b/src/plugins/android/androidanalyzesupport.cpp @@ -52,7 +52,7 @@ namespace Android { namespace Internal { RunControl *AndroidAnalyzeSupport::createAnalyzeRunControl(AndroidRunConfiguration *runConfig, - RunMode runMode) + Core::Id runMode) { Target *target = runConfig->target(); AnalyzerStartParameters params; @@ -61,7 +61,7 @@ RunControl *AndroidAnalyzeSupport::createAnalyzeRunControl(AndroidRunConfigurati params.sysroot = SysRootKitInformation::sysRoot(target->kit()).toString(); // TODO: Not sure if these are the right paths. params.workingDirectory = target->project()->projectDirectory().toString(); - if (runMode == QmlProfilerRunMode) { + if (runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) { QTcpServer server; QTC_ASSERT(server.listen(QHostAddress::LocalHost) || server.listen(QHostAddress::LocalHostIPv6), return 0); diff --git a/src/plugins/android/androidanalyzesupport.h b/src/plugins/android/androidanalyzesupport.h index 469dc7193d..610be9a1e4 100644 --- a/src/plugins/android/androidanalyzesupport.h +++ b/src/plugins/android/androidanalyzesupport.h @@ -51,7 +51,7 @@ public: Analyzer::AnalyzerRunControl *runControl); static ProjectExplorer::RunControl *createAnalyzeRunControl(AndroidRunConfiguration *runConfig, - ProjectExplorer::RunMode runMode); + Core::Id runMode); private: QmlDebug::QmlOutputParser m_outputParser; diff --git a/src/plugins/android/androidruncontrol.cpp b/src/plugins/android/androidruncontrol.cpp index 8a0bf3155a..41893846e2 100644 --- a/src/plugins/android/androidruncontrol.cpp +++ b/src/plugins/android/androidruncontrol.cpp @@ -42,8 +42,8 @@ namespace Android { namespace Internal { AndroidRunControl::AndroidRunControl(AndroidRunConfiguration *rc) - : RunControl(rc, NormalRunMode) - , m_runner(new AndroidRunner(this, rc, NormalRunMode)) + : RunControl(rc, ProjectExplorer::Constants::NORMAL_RUN_MODE) + , m_runner(new AndroidRunner(this, rc, ProjectExplorer::Constants::NORMAL_RUN_MODE)) , m_running(false) { setIcon(QLatin1String(ProjectExplorer::Constants::ICON_RUN_SMALL)); diff --git a/src/plugins/android/androidrunfactories.cpp b/src/plugins/android/androidrunfactories.cpp index 7e8673aa6a..a0a5e1cf3f 100644 --- a/src/plugins/android/androidrunfactories.cpp +++ b/src/plugins/android/androidrunfactories.cpp @@ -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 qobject_cast<AndroidRunConfiguration *>(runConfiguration); } RunControl *AndroidRunControlFactory::create(RunConfiguration *runConfig, - RunMode mode, QString *errorMessage) + Core::Id mode, QString *errorMessage) { Q_ASSERT(canRun(runConfig, mode)); AndroidRunConfiguration *rc = qobject_cast<AndroidRunConfiguration *>(runConfig); Q_ASSERT(rc); - switch (mode) { - case NormalRunMode: + if (mode == ProjectExplorer::Constants::NORMAL_RUN_MODE) 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); - case QmlProfilerRunMode: + if (mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) return AndroidAnalyzeSupport::createAnalyzeRunControl(rc, mode); - case NoRunMode: - case DebugRunModeWithBreakOnMain: - case CallgrindRunMode: - case MemcheckRunMode: - case MemcheckWithGdbRunMode: - case ClangStaticAnalyzerMode: - case PerfProfilerRunMode: - QTC_CHECK(false); // The other run modes are not supported - } + QTC_CHECK(false); // The other run modes are not supported return 0; } diff --git a/src/plugins/android/androidrunfactories.h b/src/plugins/android/androidrunfactories.h index ec3503c151..b2940fd93c 100644 --- a/src/plugins/android/androidrunfactories.h +++ b/src/plugins/android/androidrunfactories.h @@ -53,9 +53,9 @@ public: explicit AndroidRunControlFactory(QObject *parent = 0); bool canRun(ProjectExplorer::RunConfiguration *runConfiguration, - ProjectExplorer::RunMode mode) const; + Core::Id mode) const; ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration, - ProjectExplorer::RunMode mode, + Core::Id mode, QString *errorMessage); }; diff --git a/src/plugins/android/androidrunner.cpp b/src/plugins/android/androidrunner.cpp index c525440c0f..c530d008cf 100644 --- a/src/plugins/android/androidrunner.cpp +++ b/src/plugins/android/androidrunner.cpp @@ -125,21 +125,21 @@ static int socketHandShakePort = MIN_SOCKET_HANDSHAKE_PORT; AndroidRunner::AndroidRunner(QObject *parent, AndroidRunConfiguration *runConfig, - ProjectExplorer::RunMode runMode) + Core::Id runMode) : QThread(parent), m_handShakeMethod(SocketHandShake), m_socket(0), m_customPort(false) { m_tries = 0; Debugger::DebuggerRunConfigurationAspect *aspect = 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_useQmlDebugger = debuggingMode && aspect->useQmlDebugger(); QString channel = runConfig->remoteChannel(); QTC_CHECK(channel.startsWith(QLatin1Char(':'))); m_localGdbServerPort = channel.mid(1).toUShort(); QTC_CHECK(m_localGdbServerPort); - m_useQmlProfiler = runMode == ProjectExplorer::QmlProfilerRunMode; + m_useQmlProfiler = runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE; if (m_useQmlDebugger || m_useQmlProfiler) { QTcpServer server; QTC_ASSERT(server.listen(QHostAddress::LocalHost) diff --git a/src/plugins/android/androidrunner.h b/src/plugins/android/androidrunner.h index 8f6c40d573..8bf90f4e8a 100644 --- a/src/plugins/android/androidrunner.h +++ b/src/plugins/android/androidrunner.h @@ -33,7 +33,7 @@ #include "androidconfigurations.h" -#include <projectexplorer/projectexplorerconstants.h> +#include <projectexplorer/runconfiguration.h> #include <QObject> #include <QTimer> @@ -58,7 +58,7 @@ class AndroidRunner : public QThread public: AndroidRunner(QObject *parent, AndroidRunConfiguration *runConfig, - ProjectExplorer::RunMode runMode); + Core::Id runMode); ~AndroidRunner(); QString displayName() const; diff --git a/src/plugins/baremetal/baremetalruncontrolfactory.cpp b/src/plugins/baremetal/baremetalruncontrolfactory.cpp index 7dd2fb7edf..8a4cb36278 100644 --- a/src/plugins/baremetal/baremetalruncontrolfactory.cpp +++ b/src/plugins/baremetal/baremetalruncontrolfactory.cpp @@ -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; + } const QByteArray idStr = runConfiguration->id().name(); return runConfiguration->isEnabled() && idStr.startsWith(BareMetalRunConfiguration::IdPrefix); } RunControl *BareMetalRunControlFactory::create( - RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage) + RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage) { QTC_ASSERT(canRun(runConfiguration, mode), return 0); diff --git a/src/plugins/baremetal/baremetalruncontrolfactory.h b/src/plugins/baremetal/baremetalruncontrolfactory.h index 68f5e15645..55d8f4d98e 100644 --- a/src/plugins/baremetal/baremetalruncontrolfactory.h +++ b/src/plugins/baremetal/baremetalruncontrolfactory.h @@ -47,9 +47,9 @@ class BareMetalRunControlFactory : public ProjectExplorer::IRunControlFactory public: explicit BareMetalRunControlFactory(QObject *parent = 0); ~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::RunMode mode, + Core::Id mode, QString *errorMessage); }; diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 261bbfb2a8..a79bef2e8c 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -810,7 +810,7 @@ public slots: void handleExecStep() { if (currentEngine()->state() == DebuggerNotReady) { - ProjectExplorerPlugin::runStartupProject(DebugRunModeWithBreakOnMain); + ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN); } else { currentEngine()->resetLocation(); if (boolSetting(OperateByInstruction)) @@ -823,7 +823,7 @@ public slots: void handleExecNext() { if (currentEngine()->state() == DebuggerNotReady) { - ProjectExplorerPlugin::runStartupProject(DebugRunModeWithBreakOnMain); + ProjectExplorerPlugin::runStartupProject(ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN); } else { currentEngine()->resetLocation(); if (boolSetting(OperateByInstruction)) @@ -1306,7 +1306,7 @@ void DebuggerPluginPrivate::onCurrentProjectChanged(Project *project) m_continueAction->setEnabled(false); m_exitAction->setEnabled(false); 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->setToolTip(whyNot); m_debugWithoutDeployAction->setEnabled(canRun); @@ -1978,7 +1978,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine) m_localsAndExpressionsWindow->setShowLocals(false); } else if (state == DebuggerFinished) { 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. m_interruptAction->setEnabled(false); m_continueAction->setEnabled(false); @@ -2080,7 +2080,7 @@ void DebuggerPluginPrivate::updateDebugActions() Project *project = SessionManager::startupProject(); 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->setToolTip(whyNot); m_debugWithoutDeployAction->setEnabled(canRun); @@ -2089,7 +2089,7 @@ void DebuggerPluginPrivate::updateDebugActions() if (m_snapshotHandler->currentIndex() < 0) { QString toolTip; 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_nextAction->setEnabled(canRunAndBreakMain); if (canRunAndBreakMain) { @@ -2592,11 +2592,11 @@ void DebuggerPluginPrivate::extensionsInitialized() debuggerIcon.addFile(QLatin1String(":/projectexplorer/images/debugger_start.png")); act->setIcon(debuggerIcon); 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->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->setText(tr("Start and Debug External Application...")); diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp index b2e41532aa..b02ddb7291 100644 --- a/src/plugins/debugger/debuggerruncontrol.cpp +++ b/src/plugins/debugger/debuggerruncontrol.cpp @@ -70,6 +70,9 @@ namespace Debugger { namespace Internal { 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 *createPdbEngine(const DebuggerRunParameters &rp); DebuggerEngine *createQmlEngine(const DebuggerRunParameters &rp); @@ -295,7 +298,7 @@ public: // detectable pieces, construct an Engine and a RunControl. void initialize(const DebuggerStartParameters &sp); 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')); } // Result. @@ -536,7 +539,7 @@ DebuggerEngine *createEngine(DebuggerEngineType et, const DebuggerRunParameters return 0; } -void DebuggerRunControlCreator::createRunControl(RunMode runMode) +void DebuggerRunControlCreator::createRunControl(Core::Id runMode) { if (runMode == DebugRunModeWithBreakOnMain) m_rp.breakOnMain = true; @@ -569,7 +572,7 @@ public: {} RunControl *create(RunConfiguration *runConfig, - RunMode mode, QString *errorMessage) override + Core::Id mode, QString *errorMessage) override { QTC_ASSERT(runConfig, return 0); QTC_ASSERT(mode == DebugRunMode || mode == DebugRunModeWithBreakOnMain, return 0); @@ -584,7 +587,7 @@ public: 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) && qobject_cast<LocalApplicationRunConfiguration *>(runConfig); @@ -633,7 +636,7 @@ DebuggerRunControl *createAndScheduleRun(const DebuggerRunParameters &rp, const DebuggerRunControl *createDebuggerRunControl(const DebuggerStartParameters &sp, RunConfiguration *runConfig, QString *errorMessage, - RunMode runMode) + Core::Id runMode) { DebuggerRunControlCreator creator; creator.initialize(sp); diff --git a/src/plugins/debugger/debuggerruncontrol.h b/src/plugins/debugger/debuggerruncontrol.h index 00b27b6165..f7b8e85038 100644 --- a/src/plugins/debugger/debuggerruncontrol.h +++ b/src/plugins/debugger/debuggerruncontrol.h @@ -50,7 +50,7 @@ class DebuggerRunControlCreator; DEBUGGER_EXPORT DebuggerRunControl *createDebuggerRunControl(const DebuggerStartParameters &sp, ProjectExplorer::RunConfiguration *runConfig, QString *errorMessage, - ProjectExplorer::RunMode runMode = ProjectExplorer::DebugRunMode); + Core::Id runMode = ProjectExplorer::Constants::DEBUG_RUN_MODE); class DEBUGGER_EXPORT DebuggerRunControl : public ProjectExplorer::RunControl diff --git a/src/plugins/ios/iosanalyzesupport.cpp b/src/plugins/ios/iosanalyzesupport.cpp index 9f5bb0000d..ce593c9b94 100644 --- a/src/plugins/ios/iosanalyzesupport.cpp +++ b/src/plugins/ios/iosanalyzesupport.cpp @@ -84,7 +84,7 @@ RunControl *IosAnalyzeSupport::createAnalyzeRunControl(IosRunConfiguration *runC if (device.isNull()) return 0; AnalyzerStartParameters params; - params.runMode = QmlProfilerRunMode; + params.runMode = ProjectExplorer::Constants::QML_PROFILER_RUN_MODE; params.sysroot = SysRootKitInformation::sysRoot(target->kit()).toString(); params.debuggee = runConfig->localExecutable().toUserOutput(); params.debuggeeArgs = Utils::QtcProcess::joinArgs(runConfig->commandLineArguments()); diff --git a/src/plugins/ios/iosruncontrol.cpp b/src/plugins/ios/iosruncontrol.cpp index 3144574e3e..7edeb14661 100644 --- a/src/plugins/ios/iosruncontrol.cpp +++ b/src/plugins/ios/iosruncontrol.cpp @@ -41,7 +41,7 @@ namespace Ios { namespace Internal { IosRunControl::IosRunControl(IosRunConfiguration *rc) - : RunControl(rc, NormalRunMode) + : RunControl(rc, ProjectExplorer::Constants::NORMAL_RUN_MODE) , m_runner(new IosRunner(this, rc, false, false)) , m_running(false) { diff --git a/src/plugins/ios/iosrunfactories.cpp b/src/plugins/ios/iosrunfactories.cpp index f267153905..a160e3d53d 100644 --- a/src/plugins/ios/iosrunfactories.cpp +++ b/src/plugins/ios/iosrunfactories.cpp @@ -159,16 +159,20 @@ IosRunControlFactory::IosRunControlFactory(QObject *parent) } bool IosRunControlFactory::canRun(RunConfiguration *runConfiguration, - RunMode mode) const + Core::Id mode) const { - if (mode != NormalRunMode && mode != DebugRunMode && mode != QmlProfilerRunMode - && 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 + && mode != ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) { return false; + } + return qobject_cast<IosRunConfiguration *>(runConfiguration); } RunControl *IosRunControlFactory::create(RunConfiguration *runConfig, - RunMode mode, QString *errorMessage) + Core::Id mode, QString *errorMessage) { Q_ASSERT(canRun(runConfig, mode)); IosRunConfiguration *rc = qobject_cast<IosRunConfiguration *>(runConfig); @@ -181,9 +185,9 @@ RunControl *IosRunControlFactory::create(RunConfiguration *runConfig, activeRunControl->stop(); m_activeRunControls.remove(devId); } - if (mode == NormalRunMode) + if (mode == ProjectExplorer::Constants::NORMAL_RUN_MODE) res = new Ios::Internal::IosRunControl(rc); - else if (mode == QmlProfilerRunMode) + else if (mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) res = IosAnalyzeSupport::createAnalyzeRunControl(rc, errorMessage); else res = IosDebugSupport::createDebugRunControl(rc, errorMessage); diff --git a/src/plugins/ios/iosrunfactories.h b/src/plugins/ios/iosrunfactories.h index 51b566c294..79238c741c 100644 --- a/src/plugins/ios/iosrunfactories.h +++ b/src/plugins/ios/iosrunfactories.h @@ -81,9 +81,9 @@ public: explicit IosRunControlFactory(QObject *parent = 0); bool canRun(ProjectExplorer::RunConfiguration *runConfiguration, - ProjectExplorer::RunMode mode) const override; + Core::Id mode) const override; ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration, - ProjectExplorer::RunMode mode, + Core::Id mode, QString *errorMessage) override; private: mutable QMap<Core::Id, QPointer<ProjectExplorer::RunControl> > m_activeRunControls; diff --git a/src/plugins/projectexplorer/localapplicationruncontrol.cpp b/src/plugins/projectexplorer/localapplicationruncontrol.cpp index a1596b34b9..1ce1869c7c 100644 --- a/src/plugins/projectexplorer/localapplicationruncontrol.cpp +++ b/src/plugins/projectexplorer/localapplicationruncontrol.cpp @@ -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) QTC_ASSERT(canRun(runConfiguration, mode), return 0); @@ -72,7 +72,7 @@ RunControl *LocalApplicationRunControlFactory::create(RunConfiguration *runConfi // ApplicationRunControl -LocalApplicationRunControl::LocalApplicationRunControl(RunConfiguration *rc, RunMode mode) +LocalApplicationRunControl::LocalApplicationRunControl(RunConfiguration *rc, Core::Id mode) : RunControl(rc, mode), m_runMode(ApplicationLauncher::Console), m_running(false) { setIcon(QLatin1String(Constants::ICON_RUN_SMALL)); diff --git a/src/plugins/projectexplorer/localapplicationruncontrol.h b/src/plugins/projectexplorer/localapplicationruncontrol.h index dca6a02dd3..40cd52439f 100644 --- a/src/plugins/projectexplorer/localapplicationruncontrol.h +++ b/src/plugins/projectexplorer/localapplicationruncontrol.h @@ -43,8 +43,8 @@ class LocalApplicationRunControlFactory : public IRunControlFactory public: LocalApplicationRunControlFactory (); ~LocalApplicationRunControlFactory(); - bool canRun(RunConfiguration *runConfiguration, RunMode mode) const; - RunControl* create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage); + bool canRun(RunConfiguration *runConfiguration, Core::Id mode) const; + RunControl* create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage); }; } // namespace Internal @@ -53,7 +53,7 @@ class PROJECTEXPLORER_EXPORT LocalApplicationRunControl : public RunControl { Q_OBJECT public: - LocalApplicationRunControl(RunConfiguration *runConfiguration, RunMode mode); + LocalApplicationRunControl(RunConfiguration *runConfiguration, Core::Id mode); ~LocalApplicationRunControl(); void start(); StopResult stop(); diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index ded797906d..3bfd73b1e1 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -203,12 +203,12 @@ public: void deploy(QList<Project *>); int queue(QList<Project *>, QList<Id> stepIds); void updateContextMenuActions(); - void executeRunConfiguration(RunConfiguration *, RunMode mode); + void executeRunConfiguration(RunConfiguration *, Core::Id mode); QPair<bool, QString> buildSettingsEnabledForSession(); QPair<bool, QString> buildSettingsEnabled(Project *pro); void addToRecentProjects(const QString &fileName, const QString &displayName); - void startRunControl(RunControl *runControl, RunMode runMode); + void startRunControl(RunControl *runControl, Core::Id runMode); void updateActions(); void updateContext(); @@ -350,9 +350,9 @@ public: QString m_lastOpenDirectory; QPointer<RunConfiguration> m_delayedRunConfiguration; - QList<QPair<RunConfiguration *, RunMode>> m_delayedRunConfigurationForRun; + QList<QPair<RunConfiguration *, Core::Id>> m_delayedRunConfigurationForRun; bool m_shouldHaveRunConfiguration; - RunMode m_runMode; + Core::Id m_runMode; QString m_projectFilterString; MiniProjectTargetSelector * m_targetSelector; ProjectExplorerSettings m_projectExplorerSettings; @@ -373,7 +373,7 @@ public: ProjectExplorerPluginPrivate::ProjectExplorerPluginPrivate() : m_shouldHaveRunConfiguration(false), - m_runMode(NoRunMode), + m_runMode(Constants::NO_RUN_MODE), m_projectsMode(0), m_kitManager(0), m_toolChainManager(0), @@ -1901,7 +1901,7 @@ void ProjectExplorerPluginPrivate::buildStateChanged(Project * pro) } // NBS TODO implement more than one runner -static IRunControlFactory *findRunControlFactory(RunConfiguration *config, RunMode mode) +static IRunControlFactory *findRunControlFactory(RunConfiguration *config, Core::Id mode) { return ExtensionSystem::PluginManager::getObject<IRunControlFactory>( [&config, &mode](IRunControlFactory *factory) { @@ -1909,7 +1909,7 @@ static IRunControlFactory *findRunControlFactory(RunConfiguration *config, RunMo }); } -void ProjectExplorerPluginPrivate::executeRunConfiguration(RunConfiguration *runConfiguration, RunMode runMode) +void ProjectExplorerPluginPrivate::executeRunConfiguration(RunConfiguration *runConfiguration, Core::Id runMode) { if (!runConfiguration->isConfigured()) { QString errorMessage; @@ -1947,18 +1947,18 @@ void ProjectExplorerPlugin::showRunErrorMessage(const QString &errorMessage) QMessageBox::critical(ICore::mainWindow(), errorMessage.isNull() ? tr("Unknown error") : tr("Could Not Run"), errorMessage); } -void ProjectExplorerPlugin::startRunControl(RunControl *runControl, RunMode runMode) +void ProjectExplorerPlugin::startRunControl(RunControl *runControl, Core::Id runMode) { dd->startRunControl(runControl, runMode); } -void ProjectExplorerPluginPrivate::startRunControl(RunControl *runControl, RunMode runMode) +void ProjectExplorerPluginPrivate::startRunControl(RunControl *runControl, Core::Id runMode) { m_outputPane->createNewOutputWindow(runControl); m_outputPane->flash(); // one flash for starting m_outputPane->showTabFor(runControl); - bool popup = (runMode == NormalRunMode && dd->m_projectExplorerSettings.showRunOutput) - || ((runMode == DebugRunMode || runMode == DebugRunModeWithBreakOnMain) + bool popup = (runMode == Constants::NORMAL_RUN_MODE && dd->m_projectExplorerSettings.showRunOutput) + || ((runMode == Constants::DEBUG_RUN_MODE || runMode == Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN) && m_projectExplorerSettings.showDebugOutput); m_outputPane->setBehaviorOnOutput(runControl, popup ? AppOutputPane::Popup : AppOutputPane::Flash); runControl->start(); @@ -2001,13 +2001,13 @@ void ProjectExplorerPluginPrivate::buildQueueFinished(bool success) } m_delayedRunConfiguration = 0; m_shouldHaveRunConfiguration = false; - m_runMode = NoRunMode; + m_runMode = Constants::NO_RUN_MODE; } void ProjectExplorerPluginPrivate::runConfigurationConfigurationFinished() { RunConfiguration *rc = qobject_cast<RunConfiguration *>(sender()); - RunMode runMode = NoRunMode; + Core::Id runMode = Constants::NO_RUN_MODE; for (int i = 0; i < m_delayedRunConfigurationForRun.size(); ++i) { if (m_delayedRunConfigurationForRun.at(i).first == rc) { runMode = m_delayedRunConfigurationForRun.at(i).second; @@ -2015,7 +2015,7 @@ void ProjectExplorerPluginPrivate::runConfigurationConfigurationFinished() break; } } - if (runMode != NoRunMode && rc->isConfigured()) + if (runMode != Constants::NO_RUN_MODE && rc->isConfigured()) executeRunConfiguration(rc, runMode); } @@ -2368,12 +2368,12 @@ void ProjectExplorerPluginPrivate::cleanSession() void ProjectExplorerPluginPrivate::handleRunProject() { - m_instance->runStartupProject(NormalRunMode); + m_instance->runStartupProject(Constants::NORMAL_RUN_MODE); } void ProjectExplorerPluginPrivate::runProjectWithoutDeploy() { - m_instance->runStartupProject(NormalRunMode, true); + m_instance->runStartupProject(Constants::NORMAL_RUN_MODE, true); } void ProjectExplorerPluginPrivate::runProjectContextMenu() @@ -2381,7 +2381,7 @@ void ProjectExplorerPluginPrivate::runProjectContextMenu() Node *node = ProjectTree::currentNode(); ProjectNode *projectNode = node ? node->asProjectNode() : 0; if (projectNode == ProjectTree::currentProject()->rootProjectNode() || !projectNode) { - m_instance->runProject(ProjectTree::currentProject(), NormalRunMode); + m_instance->runProject(ProjectTree::currentProject(), Constants::NORMAL_RUN_MODE); } else { QAction *act = qobject_cast<QAction *>(sender()); if (!act) @@ -2389,7 +2389,7 @@ void ProjectExplorerPluginPrivate::runProjectContextMenu() RunConfiguration *rc = act->data().value<RunConfiguration *>(); if (!rc) return; - m_instance->runRunConfiguration(rc, NormalRunMode); + m_instance->runRunConfiguration(rc, Constants::NORMAL_RUN_MODE); } } @@ -2493,7 +2493,7 @@ static bool hasDeploySettings(Project *pro) }); } -void ProjectExplorerPlugin::runProject(Project *pro, RunMode mode, const bool forceSkipDeploy) +void ProjectExplorerPlugin::runProject(Project *pro, Core::Id mode, const bool forceSkipDeploy) { if (!pro) return; @@ -2503,13 +2503,13 @@ void ProjectExplorerPlugin::runProject(Project *pro, RunMode mode, const bool fo runRunConfiguration(rc, mode, forceSkipDeploy); } -void ProjectExplorerPlugin::runStartupProject(RunMode runMode, bool forceSkipDeploy) +void ProjectExplorerPlugin::runStartupProject(Core::Id runMode, bool forceSkipDeploy) { runProject(SessionManager::startupProject(), runMode, forceSkipDeploy); } void ProjectExplorerPlugin::runRunConfiguration(RunConfiguration *rc, - RunMode runMode, + Core::Id runMode, const bool forceSkipDeploy) { if (!rc->isEnabled()) @@ -2680,7 +2680,7 @@ void ProjectExplorerPluginPrivate::updateDeployActions() emit m_instance->updateRunActions(); } -bool ProjectExplorerPlugin::canRun(Project *project, RunMode runMode, QString *whyNot) +bool ProjectExplorerPlugin::canRun(Project *project, Core::Id runMode, QString *whyNot) { if (!project) { if (whyNot) @@ -2747,7 +2747,7 @@ void ProjectExplorerPluginPrivate::slotUpdateRunActions() { Project *project = SessionManager::startupProject(); QString whyNot; - const bool state = ProjectExplorerPlugin::canRun(project, NormalRunMode, &whyNot); + const bool state = ProjectExplorerPlugin::canRun(project, Constants::NORMAL_RUN_MODE, &whyNot); m_runAction->setEnabled(state); m_runAction->setToolTip(whyNot); m_runWithoutDeployAction->setEnabled(state); diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index e548268f71..61d86e65aa 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -33,6 +33,7 @@ #include "projectexplorer_export.h" #include "projectexplorerconstants.h" +#include "runconfiguration.h" #include <extensionsystem/iplugin.h> @@ -88,7 +89,7 @@ public: static void setProjectExplorerSettings(const Internal::ProjectExplorerSettings &pes); static Internal::ProjectExplorerSettings projectExplorerSettings(); - static void startRunControl(RunControl *runControl, RunMode runMode); + static void startRunControl(RunControl *runControl, Core::Id runMode); static void showRunErrorMessage(const QString &errorMessage); // internal public for FlatModel @@ -97,10 +98,10 @@ public: static bool coreAboutToClose(); static QList<QPair<QString, QString> > recentProjects(); - static bool canRun(Project *pro, RunMode runMode, QString *whyNot = 0); - static void runProject(Project *pro, RunMode, const bool forceSkipDeploy = false); - static void runStartupProject(RunMode runMode, bool forceSkipDeploy = false); - static void runRunConfiguration(RunConfiguration *rc, RunMode runMode, + static bool canRun(Project *pro, Core::Id runMode, QString *whyNot = 0); + static void runProject(Project *pro, Core::Id, const bool forceSkipDeploy = false); + static void runStartupProject(Core::Id runMode, bool forceSkipDeploy = false); + static void runRunConfiguration(RunConfiguration *rc, Core::Id runMode, const bool forceSkipDeploy = false); static void addExistingFiles(FolderNode *projectNode, const QStringList &filePaths); @@ -128,7 +129,7 @@ signals: // or the file list of a specific project has changed. void fileListChanged(); - void aboutToExecuteProject(ProjectExplorer::Project *project, RunMode runMode); + void aboutToExecuteProject(ProjectExplorer::Project *project, Core::Id runMode); void recentProjectsChanged(); void settingsChanged(); diff --git a/src/plugins/projectexplorer/projectexplorerconstants.h b/src/plugins/projectexplorer/projectexplorerconstants.h index 37a346332c..c6ec2b89cf 100644 --- a/src/plugins/projectexplorer/projectexplorerconstants.h +++ b/src/plugins/projectexplorer/projectexplorerconstants.h @@ -267,22 +267,14 @@ const char SHOW_FILE_FILTER_DEFAULT[] = "*.c; *.cc; *.cpp; *.cp; *.cxx; *.c++; * const char PAGE_ID_PREFIX[] = "PE.Wizard.Page."; const char GENERATOR_ID_PREFIX[] = "PE.Wizard.Generator."; -} // namespace Constants - -// Run modes -enum RunMode { - NoRunMode, - NormalRunMode, - DebugRunMode, - DebugRunModeWithBreakOnMain, - QmlProfilerRunMode, - CallgrindRunMode, - MemcheckRunMode, - MemcheckWithGdbRunMode, - ClangStaticAnalyzerMode, - PerfProfilerRunMode -}; +// RunMode +const char NO_RUN_MODE[]="RunConfiguration.NoRunMode"; +const char NORMAL_RUN_MODE[]="RunConfiguration.NormalRunMode"; +const char QML_PROFILER_RUN_MODE[]="RunConfiguration.QmlProfilerRunMode"; +const char DEBUG_RUN_MODE[]="RunConfiguration.DebugRunMode"; +const char DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN[]="RunConfiguration.DebugRunModeWithBreakOnMain"; +} // namespace Constants } // namespace ProjectExplorer #endif // PROJECTEXPLORERCONSTANTS_H diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 12f044677e..8c3fdf8254 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -51,7 +51,7 @@ #include <ApplicationServices/ApplicationServices.h> #endif -using namespace ProjectExplorer; +namespace ProjectExplorer { /*! \class ProjectExplorer::ProcessHandle @@ -515,7 +515,7 @@ IRunConfigurationAspect *IRunControlFactory::createRunConfigurationAspect(RunCon than it needs to be. */ -RunControl::RunControl(RunConfiguration *runConfiguration, RunMode mode) +RunControl::RunControl(RunConfiguration *runConfiguration, Core::Id mode) : m_runMode(mode), m_runConfiguration(runConfiguration), m_outputFormatter(0) { if (runConfiguration) { @@ -537,7 +537,7 @@ Utils::OutputFormatter *RunControl::outputFormatter() return m_outputFormatter; } -RunMode RunControl::runMode() const +Core::Id RunControl::runMode() const { return m_runMode; } @@ -663,3 +663,5 @@ void RunControl::appendMessage(const QString &msg, Utils::OutputFormat format) { emit appendMessage(this, msg, format); } + +} // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index 43890d3ad9..ff511a84a7 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -253,8 +253,8 @@ public: explicit IRunControlFactory(QObject *parent = 0); virtual ~IRunControlFactory(); - virtual bool canRun(RunConfiguration *runConfiguration, RunMode mode) const = 0; - virtual RunControl *create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage) = 0; + virtual bool canRun(RunConfiguration *runConfiguration, Core::Id mode) const = 0; + virtual RunControl *create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage) = 0; virtual IRunConfigurationAspect *createRunConfigurationAspect(RunConfiguration *rc); }; @@ -283,7 +283,7 @@ public: AsynchronousStop // Stop sequence has been started }; - RunControl(RunConfiguration *runConfiguration, RunMode mode); + RunControl(RunConfiguration *runConfiguration, Core::Id mode); virtual ~RunControl(); virtual void start() = 0; @@ -304,7 +304,7 @@ public: bool sameRunConfiguration(const RunControl *other) const; Utils::OutputFormatter *outputFormatter(); - RunMode runMode() const; + Core::Id runMode() const; public slots: void bringApplicationToForeground(qint64 pid); @@ -328,7 +328,7 @@ protected: private: QString m_displayName; - RunMode m_runMode; + Core::Id m_runMode; QString m_icon; const QPointer<RunConfiguration> m_runConfiguration; Utils::OutputFormatter *m_outputFormatter; diff --git a/src/plugins/pythoneditor/pythoneditorplugin.cpp b/src/plugins/pythoneditor/pythoneditorplugin.cpp index 4484ed14a9..eab59f24f6 100644 --- a/src/plugins/pythoneditor/pythoneditorplugin.cpp +++ b/src/plugins/pythoneditor/pythoneditorplugin.cpp @@ -406,7 +406,7 @@ private: class PythonRunControl : public RunControl { public: - PythonRunControl(PythonRunConfiguration *runConfiguration, RunMode mode); + PythonRunControl(PythonRunConfiguration *runConfiguration, Core::Id mode); void start(); StopResult stop(); @@ -1098,16 +1098,16 @@ bool PythonProjectNode::renameFile(const QString &filePath, const QString &newFi class PythonRunControlFactory : public IRunControlFactory { public: - bool canRun(RunConfiguration *runConfiguration, RunMode mode) const; - RunControl *create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage); + bool canRun(RunConfiguration *runConfiguration, Core::Id mode) const; + RunControl *create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage); }; -bool PythonRunControlFactory::canRun(RunConfiguration *runConfiguration, RunMode mode) const +bool PythonRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id mode) const { - return mode == NormalRunMode && dynamic_cast<PythonRunConfiguration *>(runConfiguration); + return mode == ProjectExplorer::Constants::NORMAL_RUN_MODE && dynamic_cast<PythonRunConfiguration *>(runConfiguration); } -RunControl *PythonRunControlFactory::create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage) +RunControl *PythonRunControlFactory::create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage) { Q_UNUSED(errorMessage) QTC_ASSERT(canRun(runConfiguration, mode), return 0); @@ -1116,7 +1116,7 @@ RunControl *PythonRunControlFactory::create(RunConfiguration *runConfiguration, // PythonRunControl -PythonRunControl::PythonRunControl(PythonRunConfiguration *rc, RunMode mode) +PythonRunControl::PythonRunControl(PythonRunConfiguration *rc, Core::Id mode) : RunControl(rc, mode), m_running(false) { setIcon(QLatin1String(ProjectExplorer::Constants::ICON_RUN_SMALL)); diff --git a/src/plugins/qmlprofiler/qmlprofilerplugin.cpp b/src/plugins/qmlprofiler/qmlprofilerplugin.cpp index 283e1f3b83..adb1db87dc 100644 --- a/src/plugins/qmlprofiler/qmlprofilerplugin.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerplugin.cpp @@ -71,7 +71,7 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS action->setWidgetCreator(widgetCreator); action->setRunControlCreator(runControlCreator); action->setToolPreparer([tool] { return tool->prepareTool(); }); - action->setRunMode(ProjectExplorer::QmlProfilerRunMode); + action->setRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); action->setText(tr("QML Profiler")); action->setToolTip(description); action->setMenuGroup(Constants::G_ANALYZER_TOOLS); @@ -84,7 +84,7 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS action->setRunControlCreator(runControlCreator); action->setCustomToolStarter([tool] { tool->startRemoteTool(); }); action->setToolPreparer([tool] { return tool->prepareTool(); }); - action->setRunMode(ProjectExplorer::QmlProfilerRunMode); + action->setRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); action->setText(tr("QML Profiler (External)")); action->setToolTip(description); action->setMenuGroup(Constants::G_ANALYZER_REMOTE_TOOLS); diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp b/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp index a5ea4fa003..6fc364d347 100644 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.cpp @@ -57,9 +57,9 @@ QmlProfilerRunControlFactory::QmlProfilerRunControlFactory(QObject *parent) : { } -bool QmlProfilerRunControlFactory::canRun(RunConfiguration *runConfiguration, RunMode mode) const +bool QmlProfilerRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id mode) const { - return mode == QmlProfilerRunMode + return mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE && (qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration)); } @@ -83,7 +83,7 @@ static AnalyzerStartParameters createQmlProfilerStartParameters(RunConfiguration return sp; } -RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage) +RunControl *QmlProfilerRunControlFactory::create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage) { QTC_ASSERT(canRun(runConfiguration, mode), return 0); diff --git a/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.h b/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.h index f5513c98ca..269895b36c 100644 --- a/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.h +++ b/src/plugins/qmlprofiler/qmlprofilerruncontrolfactory.h @@ -45,10 +45,10 @@ public: explicit QmlProfilerRunControlFactory(QObject *parent = 0); // IRunControlFactory implementation - bool canRun(RunConfiguration *runConfiguration, ProjectExplorer::RunMode mode) const; + bool canRun(RunConfiguration *runConfiguration, Core::Id mode) const; ProjectExplorer::RunControl *create(RunConfiguration *runConfiguration, - ProjectExplorer::RunMode mode, + Core::Id mode, QString *errorMessage); }; diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index f565557200..c0518cc613 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -486,7 +486,7 @@ void QmlProfilerTool::startRemoteTool() sp.analyzerPort = port; AnalyzerRunControl *rc = createRunControl(sp, 0); - ProjectExplorerPlugin::startRunControl(rc, QmlProfilerRunMode); + ProjectExplorerPlugin::startRunControl(rc, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE); } void QmlProfilerTool::logState(const QString &msg) diff --git a/src/plugins/qnx/qnxattachdebugsupport.cpp b/src/plugins/qnx/qnxattachdebugsupport.cpp index dac8912da4..3bb3f271a9 100644 --- a/src/plugins/qnx/qnxattachdebugsupport.cpp +++ b/src/plugins/qnx/qnxattachdebugsupport.cpp @@ -135,7 +135,7 @@ void QnxAttachDebugSupport::attachToProcess() } connect(runControl, &Debugger::DebuggerRunControl::stateChanged, this, &QnxAttachDebugSupport::handleDebuggerStateChanged); - ProjectExplorer::ProjectExplorerPlugin::startRunControl(runControl, ProjectExplorer::DebugRunMode); + ProjectExplorer::ProjectExplorerPlugin::startRunControl(runControl, ProjectExplorer::Constants::DEBUG_RUN_MODE); } void QnxAttachDebugSupport::handleDebuggerStateChanged(Debugger::DebuggerState state) diff --git a/src/plugins/qnx/qnxruncontrolfactory.cpp b/src/plugins/qnx/qnxruncontrolfactory.cpp index 2e943e0a1b..ee5c37044c 100644 --- a/src/plugins/qnx/qnxruncontrolfactory.cpp +++ b/src/plugins/qnx/qnxruncontrolfactory.cpp @@ -95,7 +95,7 @@ static DebuggerStartParameters createDebuggerStartParameters(QnxRunConfiguration return params; } -static AnalyzerStartParameters createAnalyzerStartParameters(const QnxRunConfiguration *runConfig, RunMode mode) +static AnalyzerStartParameters createAnalyzerStartParameters(const QnxRunConfiguration *runConfig, Core::Id mode) { AnalyzerStartParameters params; Target *target = runConfig->target(); @@ -125,10 +125,13 @@ QnxRunControlFactory::QnxRunControlFactory(QObject *parent) { } -bool QnxRunControlFactory::canRun(RunConfiguration *runConfiguration, RunMode mode) const +bool QnxRunControlFactory::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::QML_PROFILER_RUN_MODE) { return false; + } if (!runConfiguration->isEnabled() || !runConfiguration->id().name().startsWith(Constants::QNX_QNX_RUNCONFIGURATION_PREFIX)) { @@ -141,22 +144,22 @@ bool QnxRunControlFactory::canRun(RunConfiguration *runConfiguration, RunMode mo if (dev.isNull()) return false; - if (mode == DebugRunMode || mode == QmlProfilerRunMode) + if (mode == ProjectExplorer::Constants::DEBUG_RUN_MODE || mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) return rc->portsUsedByDebuggers() <= dev->freePorts().count(); return true; } -RunControl *QnxRunControlFactory::create(RunConfiguration *runConfig, RunMode mode, QString *errorMessage) +RunControl *QnxRunControlFactory::create(RunConfiguration *runConfig, Core::Id mode, QString *errorMessage) { Q_ASSERT(canRun(runConfig, mode)); QnxRunConfiguration *rc = qobject_cast<QnxRunConfiguration *>(runConfig); Q_ASSERT(rc); - switch (mode) { - case NormalRunMode: + if (mode == ProjectExplorer::Constants::NORMAL_RUN_MODE) return new QnxRunControl(rc); - case DebugRunMode: { + + if (mode == ProjectExplorer::Constants::DEBUG_RUN_MODE) { const DebuggerStartParameters params = createDebuggerStartParameters(rc); DebuggerRunControl *runControl = createDebuggerRunControl(params, runConfig, errorMessage); if (!runControl) @@ -167,21 +170,15 @@ RunControl *QnxRunControlFactory::create(RunConfiguration *runConfig, RunMode mo return runControl; } - case QmlProfilerRunMode: { + + if (mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) { const AnalyzerStartParameters params = createAnalyzerStartParameters(rc, mode); AnalyzerRunControl *runControl = AnalyzerManager::createRunControl(params, runConfig); QnxAnalyzeSupport * const analyzeSupport = new QnxAnalyzeSupport(rc, runControl); connect(runControl, SIGNAL(finished()), analyzeSupport, SLOT(handleProfilingFinished())); return runControl; } - case PerfProfilerRunMode: - case NoRunMode: - case CallgrindRunMode: - case MemcheckRunMode: - case MemcheckWithGdbRunMode: - case ClangStaticAnalyzerMode: - case DebugRunModeWithBreakOnMain: - QTC_ASSERT(false, return 0); - } + + QTC_CHECK(false); return 0; } diff --git a/src/plugins/qnx/qnxruncontrolfactory.h b/src/plugins/qnx/qnxruncontrolfactory.h index afd6e6a585..f3753f49b8 100644 --- a/src/plugins/qnx/qnxruncontrolfactory.h +++ b/src/plugins/qnx/qnxruncontrolfactory.h @@ -46,9 +46,9 @@ public: explicit QnxRunControlFactory(QObject *parent = 0); bool canRun(ProjectExplorer::RunConfiguration *runConfiguration, - ProjectExplorer::RunMode mode) const; + Core::Id mode) const; ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration, - ProjectExplorer::RunMode mode, QString *errorMessage); + Core::Id mode, QString *errorMessage); }; } // namespace Internal diff --git a/src/plugins/remotelinux/remotelinuxanalyzesupport.cpp b/src/plugins/remotelinux/remotelinuxanalyzesupport.cpp index ea2020e15e..a7316280e9 100644 --- a/src/plugins/remotelinux/remotelinuxanalyzesupport.cpp +++ b/src/plugins/remotelinux/remotelinuxanalyzesupport.cpp @@ -56,9 +56,9 @@ namespace Internal { class RemoteLinuxAnalyzeSupportPrivate { public: - RemoteLinuxAnalyzeSupportPrivate(AnalyzerRunControl *rc, RunMode runMode) + RemoteLinuxAnalyzeSupportPrivate(AnalyzerRunControl *rc, Core::Id runMode) : runControl(rc), - qmlProfiling(runMode == QmlProfilerRunMode), + qmlProfiling(runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE), qmlPort(-1) { } @@ -75,7 +75,7 @@ public: using namespace Internal; AnalyzerStartParameters RemoteLinuxAnalyzeSupport::startParameters(const RunConfiguration *runConfig, - RunMode runMode) + Core::Id runMode) { AnalyzerStartParameters params; params.runMode = runMode; @@ -88,7 +88,7 @@ AnalyzerStartParameters RemoteLinuxAnalyzeSupport::startParameters(const RunConf } RemoteLinuxAnalyzeSupport::RemoteLinuxAnalyzeSupport(AbstractRemoteLinuxRunConfiguration *runConfig, - AnalyzerRunControl *engine, RunMode runMode) + AnalyzerRunControl *engine, Core::Id runMode) : AbstractRemoteLinuxRunSupport(runConfig, engine), d(new RemoteLinuxAnalyzeSupportPrivate(engine, runMode)) { diff --git a/src/plugins/remotelinux/remotelinuxanalyzesupport.h b/src/plugins/remotelinux/remotelinuxanalyzesupport.h index 20ff11d802..b5e3694af4 100644 --- a/src/plugins/remotelinux/remotelinuxanalyzesupport.h +++ b/src/plugins/remotelinux/remotelinuxanalyzesupport.h @@ -53,10 +53,10 @@ class REMOTELINUX_EXPORT RemoteLinuxAnalyzeSupport : public AbstractRemoteLinuxR Q_OBJECT public: static Analyzer::AnalyzerStartParameters startParameters(const ProjectExplorer::RunConfiguration *runConfig, - ProjectExplorer::RunMode runMode); + Core::Id runMode); RemoteLinuxAnalyzeSupport(AbstractRemoteLinuxRunConfiguration *runConfig, - Analyzer::AnalyzerRunControl *engine, ProjectExplorer::RunMode runMode); + Analyzer::AnalyzerRunControl *engine, Core::Id runMode); ~RemoteLinuxAnalyzeSupport(); protected: diff --git a/src/plugins/remotelinux/remotelinuxruncontrol.cpp b/src/plugins/remotelinux/remotelinuxruncontrol.cpp index 4d359f8267..7525ba93b2 100644 --- a/src/plugins/remotelinux/remotelinuxruncontrol.cpp +++ b/src/plugins/remotelinux/remotelinuxruncontrol.cpp @@ -57,7 +57,7 @@ public: }; RemoteLinuxRunControl::RemoteLinuxRunControl(RunConfiguration *rc) - : RunControl(rc, NormalRunMode), d(new RemoteLinuxRunControlPrivate) + : RunControl(rc, ProjectExplorer::Constants::NORMAL_RUN_MODE), d(new RemoteLinuxRunControlPrivate) { setIcon(QLatin1String(ProjectExplorer::Constants::ICON_RUN_SMALL)); diff --git a/src/plugins/remotelinux/remotelinuxruncontrolfactory.cpp b/src/plugins/remotelinux/remotelinuxruncontrolfactory.cpp index e933918b7d..3053e39027 100644 --- a/src/plugins/remotelinux/remotelinuxruncontrolfactory.cpp +++ b/src/plugins/remotelinux/remotelinuxruncontrolfactory.cpp @@ -63,10 +63,12 @@ RemoteLinuxRunControlFactory::~RemoteLinuxRunControlFactory() { } -bool RemoteLinuxRunControlFactory::canRun(RunConfiguration *runConfiguration, RunMode mode) const +bool RemoteLinuxRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id mode) const { - if (mode != NormalRunMode && mode != DebugRunMode && mode != DebugRunModeWithBreakOnMain - && 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; } @@ -76,16 +78,16 @@ bool RemoteLinuxRunControlFactory::canRun(RunConfiguration *runConfiguration, Ru || id.name().startsWith(RemoteLinuxRunConfiguration::IdPrefix)); } -RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, RunMode mode, +RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, Core::Id mode, QString *errorMessage) { QTC_ASSERT(canRun(runConfig, mode), return 0); - switch (mode) { - case NormalRunMode: + if (mode == ProjectExplorer::Constants::NORMAL_RUN_MODE) return new RemoteLinuxRunControl(runConfig); - case DebugRunMode: - case DebugRunModeWithBreakOnMain: { + + if (mode == ProjectExplorer::Constants::DEBUG_RUN_MODE + || mode == ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN) { IDevice::ConstPtr dev = DeviceKitInformation::device(runConfig->target()->kit()); if (!dev) { *errorMessage = tr("Cannot debug: Kit has no device."); @@ -112,7 +114,8 @@ RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, Ru connect(runControl, SIGNAL(finished()), debugSupport, SLOT(handleDebuggingFinished())); return runControl; } - case QmlProfilerRunMode: { + + if (mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) { AnalyzerStartParameters params = RemoteLinuxAnalyzeSupport::startParameters(runConfig, mode); auto * const rc = qobject_cast<AbstractRemoteLinuxRunConfiguration *>(runConfig); QTC_ASSERT(rc, return 0); @@ -120,16 +123,8 @@ RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, Ru (void) new RemoteLinuxAnalyzeSupport(rc, runControl, mode); return runControl; } - case PerfProfilerRunMode: - case NoRunMode: - case CallgrindRunMode: - case MemcheckRunMode: - case MemcheckWithGdbRunMode: - case ClangStaticAnalyzerMode: - QTC_ASSERT(false, return 0); - } - QTC_ASSERT(false, return 0); + QTC_CHECK(false); return 0; } diff --git a/src/plugins/remotelinux/remotelinuxruncontrolfactory.h b/src/plugins/remotelinux/remotelinuxruncontrolfactory.h index b8a8aa3450..fb8828248e 100644 --- a/src/plugins/remotelinux/remotelinuxruncontrolfactory.h +++ b/src/plugins/remotelinux/remotelinuxruncontrolfactory.h @@ -43,9 +43,9 @@ public: ~RemoteLinuxRunControlFactory(); bool canRun(ProjectExplorer::RunConfiguration *runConfiguration, - ProjectExplorer::RunMode mode) const; + Core::Id mode) const; ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration, - ProjectExplorer::RunMode mode, QString *errorMessage); + Core::Id mode, QString *errorMessage); }; } // namespace Internal diff --git a/src/plugins/valgrind/callgrindtool.h b/src/plugins/valgrind/callgrindtool.h index 0018ecab2a..0ef8905c6b 100644 --- a/src/plugins/valgrind/callgrindtool.h +++ b/src/plugins/valgrind/callgrindtool.h @@ -41,6 +41,8 @@ const char CallgrindLocalActionId[] = "Callgrind.Local"; const char CallgrindRemoteActionId[] = "Callgrind.Remote"; class ValgrindRunControl; +const char CALLGRIND_RUN_MODE[] = "CallgrindTool.CallgrindRunMode"; + class CallgrindToolPrivate; class CallgrindTool : public QObject diff --git a/src/plugins/valgrind/memchecktool.h b/src/plugins/valgrind/memchecktool.h index 6e9cdaae1c..2f0f593e7d 100644 --- a/src/plugins/valgrind/memchecktool.h +++ b/src/plugins/valgrind/memchecktool.h @@ -50,6 +50,10 @@ class Error; } namespace Valgrind { + +const char MEMCHECK_RUN_MODE[] = "MemcheckTool.MemcheckRunMode"; +const char MEMCHECK_WITH_GDB_RUN_MODE[] = "MemcheckTool.MemcheckWithGdbRunMode"; + namespace Internal { class FrameFinder; @@ -57,6 +61,7 @@ class MemcheckErrorView; class MemcheckRunControl; class ValgrindBaseSettings; + class MemcheckErrorFilterProxyModel : public QSortFilterProxyModel { Q_OBJECT diff --git a/src/plugins/valgrind/valgrindplugin.cpp b/src/plugins/valgrind/valgrindplugin.cpp index f8efdf3352..f92b648230 100644 --- a/src/plugins/valgrind/valgrindplugin.cpp +++ b/src/plugins/valgrind/valgrindplugin.cpp @@ -54,7 +54,6 @@ #include <cppeditor/cppeditorconstants.h> #include <projectexplorer/projectexplorer.h> -#include <projectexplorer/projectexplorerconstants.h> #include <utils/hostosinfo.h> @@ -166,7 +165,7 @@ void ValgrindPlugin::extensionsInitialized() action->setWidgetCreator(mcWidgetCreator); action->setRunControlCreator(mcRunControlCreator); action->setToolMode(DebugMode); - action->setRunMode(ProjectExplorer::MemcheckRunMode); + action->setRunMode(MEMCHECK_RUN_MODE); action->setText(tr("Valgrind Memory Analyzer")); action->setToolTip(memcheckToolTip); action->setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS); @@ -182,7 +181,7 @@ void ValgrindPlugin::extensionsInitialized() action->setRunControlCreator(std::bind(&MemcheckWithGdbTool::createRunControl, mcgTool, _1, _2)); action->setToolMode(DebugMode); - action->setRunMode(ProjectExplorer::MemcheckWithGdbRunMode); + action->setRunMode(MEMCHECK_WITH_GDB_RUN_MODE); action->setText(tr("Valgrind Memory Analyzer with GDB")); action->setToolTip(tr("Valgrind Analyze Memory with GDB uses the " "Memcheck tool to find memory leaks.\nWhen a problem is detected, " @@ -197,7 +196,7 @@ void ValgrindPlugin::extensionsInitialized() action->setWidgetCreator(cgWidgetCreator); action->setRunControlCreator(cgRunControlCreator); action->setToolMode(ReleaseMode); - action->setRunMode(CallgrindRunMode); + action->setRunMode(CALLGRIND_RUN_MODE); action->setText(tr("Valgrind Function Profiler")); action->setToolTip(callgrindToolTip); action->setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS); @@ -216,7 +215,7 @@ void ValgrindPlugin::extensionsInitialized() ValgrindRunControl *rc = mcTool->createRunControl(sp, 0); QTC_ASSERT(rc, return); rc->setCustomStart(); - ProjectExplorerPlugin::startRunControl(rc, MemcheckRunMode); + ProjectExplorerPlugin::startRunControl(rc, MEMCHECK_RUN_MODE); }); action->setText(tr("Valgrind Memory Analyzer (External Remote Application)")); action->setToolTip(memcheckToolTip); @@ -234,7 +233,7 @@ void ValgrindPlugin::extensionsInitialized() ValgrindRunControl *rc = cgTool->createRunControl(sp, 0); QTC_ASSERT(rc, return); rc->setCustomStart(); - ProjectExplorerPlugin::startRunControl(rc, CallgrindRunMode); + ProjectExplorerPlugin::startRunControl(rc, CALLGRIND_RUN_MODE); }); action->setText(tr("Valgrind Function Profiler (External Remote Application)")); diff --git a/src/plugins/valgrind/valgrindplugin.h b/src/plugins/valgrind/valgrindplugin.h index 912c3ce502..a53152903f 100644 --- a/src/plugins/valgrind/valgrindplugin.h +++ b/src/plugins/valgrind/valgrindplugin.h @@ -34,6 +34,7 @@ #include <extensionsystem/iplugin.h> #include <analyzerbase/ianalyzertool.h> +#include <projectexplorer/projectexplorer.h> namespace Valgrind { namespace Internal { diff --git a/src/plugins/valgrind/valgrindruncontrolfactory.cpp b/src/plugins/valgrind/valgrindruncontrolfactory.cpp index 23b393d2bb..32f214b2ec 100644 --- a/src/plugins/valgrind/valgrindruncontrolfactory.cpp +++ b/src/plugins/valgrind/valgrindruncontrolfactory.cpp @@ -31,6 +31,8 @@ #include "valgrindruncontrolfactory.h" #include "valgrindsettings.h" #include "valgrindplugin.h" +#include "callgrindtool.h" +#include "memchecktool.h" #include <analyzerbase/ianalyzertool.h> #include <analyzerbase/analyzermanager.h> @@ -62,13 +64,13 @@ ValgrindRunControlFactory::ValgrindRunControlFactory(QObject *parent) : { } -bool ValgrindRunControlFactory::canRun(RunConfiguration *runConfiguration, RunMode mode) const +bool ValgrindRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id mode) const { Q_UNUSED(runConfiguration); - return mode == CallgrindRunMode || mode == MemcheckRunMode || mode == MemcheckWithGdbRunMode; + return mode == CALLGRIND_RUN_MODE || mode == MEMCHECK_RUN_MODE || mode == MEMCHECK_WITH_GDB_RUN_MODE; } -RunControl *ValgrindRunControlFactory::create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage) +RunControl *ValgrindRunControlFactory::create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage) { Q_UNUSED(errorMessage); diff --git a/src/plugins/valgrind/valgrindruncontrolfactory.h b/src/plugins/valgrind/valgrindruncontrolfactory.h index 2b04b33b46..6c30632539 100644 --- a/src/plugins/valgrind/valgrindruncontrolfactory.h +++ b/src/plugins/valgrind/valgrindruncontrolfactory.h @@ -45,10 +45,10 @@ public: explicit ValgrindRunControlFactory(QObject *parent = 0); // IRunControlFactory implementation - bool canRun(RunConfiguration *runConfiguration, ProjectExplorer::RunMode mode) const; + bool canRun(RunConfiguration *runConfiguration, Core::Id mode) const; ProjectExplorer::RunControl *create(RunConfiguration *runConfiguration, - ProjectExplorer::RunMode mode, + Core::Id mode, QString *errorMessage); ProjectExplorer::IRunConfigurationAspect *createRunConfigurationAspect(ProjectExplorer::RunConfiguration *rc); }; diff --git a/src/plugins/winrt/winrtdebugsupport.cpp b/src/plugins/winrt/winrtdebugsupport.cpp index 85b56b91c4..0f25380fc8 100644 --- a/src/plugins/winrt/winrtdebugsupport.cpp +++ b/src/plugins/winrt/winrtdebugsupport.cpp @@ -68,7 +68,7 @@ void WinRtDebugSupport::finish() } RunControl *WinRtDebugSupport::createDebugRunControl(WinRtRunConfiguration *runConfig, - RunMode mode, + Core::Id mode, QString *errorMessage) { // FIXME: This is just working for local debugging; diff --git a/src/plugins/winrt/winrtdebugsupport.h b/src/plugins/winrt/winrtdebugsupport.h index 4b5d8d5cf3..f92281beb2 100644 --- a/src/plugins/winrt/winrtdebugsupport.h +++ b/src/plugins/winrt/winrtdebugsupport.h @@ -47,7 +47,7 @@ class WinRtDebugSupport : public QObject Q_OBJECT public: static ProjectExplorer::RunControl *createDebugRunControl(WinRtRunConfiguration *runConfig, - ProjectExplorer::RunMode mode, + Core::Id mode, QString *errorMessage); ~WinRtDebugSupport(); diff --git a/src/plugins/winrt/winrtruncontrol.cpp b/src/plugins/winrt/winrtruncontrol.cpp index 6e0b41d0f4..fed9db9635 100644 --- a/src/plugins/winrt/winrtruncontrol.cpp +++ b/src/plugins/winrt/winrtruncontrol.cpp @@ -48,13 +48,13 @@ using ProjectExplorer::DeviceKitInformation; using ProjectExplorer::IDevice; using ProjectExplorer::RunControl; -using ProjectExplorer::RunMode; +using Core::Id; using ProjectExplorer::Target; namespace WinRt { namespace Internal { -WinRtRunControl::WinRtRunControl(WinRtRunConfiguration *runConfiguration, RunMode mode) +WinRtRunControl::WinRtRunControl(WinRtRunConfiguration *runConfiguration, Core::Id mode) : RunControl(runConfiguration, mode) , m_runConfiguration(runConfiguration) , m_state(StoppedState) diff --git a/src/plugins/winrt/winrtruncontrol.h b/src/plugins/winrt/winrtruncontrol.h index 9b63fe89c3..ed25928687 100644 --- a/src/plugins/winrt/winrtruncontrol.h +++ b/src/plugins/winrt/winrtruncontrol.h @@ -54,7 +54,7 @@ class WinRtRunControl : public ProjectExplorer::RunControl { Q_OBJECT public: - explicit WinRtRunControl(WinRtRunConfiguration *runConfiguration, ProjectExplorer::RunMode mode); + explicit WinRtRunControl(WinRtRunConfiguration *runConfiguration, Core::Id mode); void start(); StopResult stop(); diff --git a/src/plugins/winrt/winrtrunfactories.cpp b/src/plugins/winrt/winrtrunfactories.cpp index 14336fb530..859ca9c1b4 100644 --- a/src/plugins/winrt/winrtrunfactories.cpp +++ b/src/plugins/winrt/winrtrunfactories.cpp @@ -137,7 +137,7 @@ WinRtRunControlFactory::WinRtRunControlFactory() } bool WinRtRunControlFactory::canRun(RunConfiguration *runConfiguration, - RunMode mode) const + Core::Id mode) const { if (!runConfiguration) return false; @@ -145,35 +145,32 @@ bool WinRtRunControlFactory::canRun(RunConfiguration *runConfiguration, if (!device) return false; - switch (mode) { - case DebugRunMode: - case DebugRunModeWithBreakOnMain: + if (mode == ProjectExplorer::Constants::DEBUG_RUN_MODE + || mode == ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN) { if (device->type() != Constants::WINRT_DEVICE_TYPE_LOCAL) return false; - // fall through - case NormalRunMode: return qobject_cast<WinRtRunConfiguration *>(runConfiguration); - default: - return false; } + + if (mode == ProjectExplorer::Constants::NORMAL_RUN_MODE) + return qobject_cast<WinRtRunConfiguration *>(runConfiguration); + + return false; } RunControl *WinRtRunControlFactory::create( - RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage) + RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage) { WinRtRunConfiguration *rc = qobject_cast<WinRtRunConfiguration *>(runConfiguration); QTC_ASSERT(rc, return 0); - switch (mode) { - case NormalRunMode: + if (mode == ProjectExplorer::Constants::NORMAL_RUN_MODE) return new WinRtRunControl(rc, mode); - case DebugRunMode: - case DebugRunModeWithBreakOnMain: + + if (mode == ProjectExplorer::Constants::DEBUG_RUN_MODE || mode == ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN) return WinRtDebugSupport::createDebugRunControl(rc, mode, errorMessage); - default: - break; - } - *errorMessage = tr("Unsupported run mode %1.").arg(mode); + + *errorMessage = tr("Unsupported run mode %1.").arg(mode.toString()); return 0; } diff --git a/src/plugins/winrt/winrtrunfactories.h b/src/plugins/winrt/winrtrunfactories.h index 0e310e88d7..b77868bab3 100644 --- a/src/plugins/winrt/winrtrunfactories.h +++ b/src/plugins/winrt/winrtrunfactories.h @@ -64,9 +64,9 @@ class WinRtRunControlFactory : public ProjectExplorer::IRunControlFactory public: WinRtRunControlFactory(); bool canRun(ProjectExplorer::RunConfiguration *runConfiguration, - ProjectExplorer::RunMode mode) const; + Core::Id mode) const; ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration, - ProjectExplorer::RunMode mode, QString *errorMessage); + Core::Id mode, QString *errorMessage); QString displayName() const; }; |