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>
This commit is contained in:
BogDan Vatra
2015-06-29 10:36:29 +03:00
parent 7743664957
commit 2182ded57b
50 changed files with 218 additions and 219 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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:
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)
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)
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()
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()
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()
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..."));

View File

@@ -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:
// 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
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:
{} {}
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:
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
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);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -43,8 +43,8 @@ class LocalApplicationRunControlFactory : public IRunControlFactory
public: public:
LocalApplicationRunControlFactory (); LocalApplicationRunControlFactory ();
~LocalApplicationRunControlFactory(); ~LocalApplicationRunControlFactory();
bool canRun(RunConfiguration *runConfiguration, RunMode mode) const; bool canRun(RunConfiguration *runConfiguration, Core::Id mode) const;
RunControl* create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage); RunControl* create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage);
}; };
} // namespace Internal } // namespace Internal
@@ -53,7 +53,7 @@ class PROJECTEXPLORER_EXPORT LocalApplicationRunControl : public RunControl
{ {
Q_OBJECT Q_OBJECT
public: public:
LocalApplicationRunControl(RunConfiguration *runConfiguration, RunMode mode); LocalApplicationRunControl(RunConfiguration *runConfiguration, Core::Id mode);
~LocalApplicationRunControl(); ~LocalApplicationRunControl();
void start(); void start();
StopResult stop(); StopResult stop();

View File

@@ -203,12 +203,12 @@ public:
void deploy(QList<Project *>); void deploy(QList<Project *>);
int queue(QList<Project *>, QList<Id> stepIds); int queue(QList<Project *>, QList<Id> stepIds);
void updateContextMenuActions(); void updateContextMenuActions();
void executeRunConfiguration(RunConfiguration *, RunMode mode); void executeRunConfiguration(RunConfiguration *, Core::Id mode);
QPair<bool, QString> buildSettingsEnabledForSession(); QPair<bool, QString> buildSettingsEnabledForSession();
QPair<bool, QString> buildSettingsEnabled(Project *pro); QPair<bool, QString> buildSettingsEnabled(Project *pro);
void addToRecentProjects(const QString &fileName, const QString &displayName); void addToRecentProjects(const QString &fileName, const QString &displayName);
void startRunControl(RunControl *runControl, RunMode runMode); void startRunControl(RunControl *runControl, Core::Id runMode);
void updateActions(); void updateActions();
void updateContext(); void updateContext();
@@ -350,9 +350,9 @@ public:
QString m_lastOpenDirectory; QString m_lastOpenDirectory;
QPointer<RunConfiguration> m_delayedRunConfiguration; QPointer<RunConfiguration> m_delayedRunConfiguration;
QList<QPair<RunConfiguration *, RunMode>> m_delayedRunConfigurationForRun; QList<QPair<RunConfiguration *, Core::Id>> m_delayedRunConfigurationForRun;
bool m_shouldHaveRunConfiguration; bool m_shouldHaveRunConfiguration;
RunMode m_runMode; Core::Id m_runMode;
QString m_projectFilterString; QString m_projectFilterString;
MiniProjectTargetSelector * m_targetSelector; MiniProjectTargetSelector * m_targetSelector;
ProjectExplorerSettings m_projectExplorerSettings; ProjectExplorerSettings m_projectExplorerSettings;
@@ -373,7 +373,7 @@ public:
ProjectExplorerPluginPrivate::ProjectExplorerPluginPrivate() : ProjectExplorerPluginPrivate::ProjectExplorerPluginPrivate() :
m_shouldHaveRunConfiguration(false), m_shouldHaveRunConfiguration(false),
m_runMode(NoRunMode), m_runMode(Constants::NO_RUN_MODE),
m_projectsMode(0), m_projectsMode(0),
m_kitManager(0), m_kitManager(0),
m_toolChainManager(0), m_toolChainManager(0),
@@ -1901,7 +1901,7 @@ void ProjectExplorerPluginPrivate::buildStateChanged(Project * pro)
} }
// NBS TODO implement more than one runner // 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>( return ExtensionSystem::PluginManager::getObject<IRunControlFactory>(
[&config, &mode](IRunControlFactory *factory) { [&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()) { if (!runConfiguration->isConfigured()) {
QString errorMessage; 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); 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); 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->createNewOutputWindow(runControl);
m_outputPane->flash(); // one flash for starting m_outputPane->flash(); // one flash for starting
m_outputPane->showTabFor(runControl); m_outputPane->showTabFor(runControl);
bool popup = (runMode == NormalRunMode && dd->m_projectExplorerSettings.showRunOutput) bool popup = (runMode == Constants::NORMAL_RUN_MODE && dd->m_projectExplorerSettings.showRunOutput)
|| ((runMode == DebugRunMode || runMode == DebugRunModeWithBreakOnMain) || ((runMode == Constants::DEBUG_RUN_MODE || runMode == Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN)
&& m_projectExplorerSettings.showDebugOutput); && m_projectExplorerSettings.showDebugOutput);
m_outputPane->setBehaviorOnOutput(runControl, popup ? AppOutputPane::Popup : AppOutputPane::Flash); m_outputPane->setBehaviorOnOutput(runControl, popup ? AppOutputPane::Popup : AppOutputPane::Flash);
runControl->start(); runControl->start();
@@ -2001,13 +2001,13 @@ void ProjectExplorerPluginPrivate::buildQueueFinished(bool success)
} }
m_delayedRunConfiguration = 0; m_delayedRunConfiguration = 0;
m_shouldHaveRunConfiguration = false; m_shouldHaveRunConfiguration = false;
m_runMode = NoRunMode; m_runMode = Constants::NO_RUN_MODE;
} }
void ProjectExplorerPluginPrivate::runConfigurationConfigurationFinished() void ProjectExplorerPluginPrivate::runConfigurationConfigurationFinished()
{ {
RunConfiguration *rc = qobject_cast<RunConfiguration *>(sender()); 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) { for (int i = 0; i < m_delayedRunConfigurationForRun.size(); ++i) {
if (m_delayedRunConfigurationForRun.at(i).first == rc) { if (m_delayedRunConfigurationForRun.at(i).first == rc) {
runMode = m_delayedRunConfigurationForRun.at(i).second; runMode = m_delayedRunConfigurationForRun.at(i).second;
@@ -2015,7 +2015,7 @@ void ProjectExplorerPluginPrivate::runConfigurationConfigurationFinished()
break; break;
} }
} }
if (runMode != NoRunMode && rc->isConfigured()) if (runMode != Constants::NO_RUN_MODE && rc->isConfigured())
executeRunConfiguration(rc, runMode); executeRunConfiguration(rc, runMode);
} }
@@ -2368,12 +2368,12 @@ void ProjectExplorerPluginPrivate::cleanSession()
void ProjectExplorerPluginPrivate::handleRunProject() void ProjectExplorerPluginPrivate::handleRunProject()
{ {
m_instance->runStartupProject(NormalRunMode); m_instance->runStartupProject(Constants::NORMAL_RUN_MODE);
} }
void ProjectExplorerPluginPrivate::runProjectWithoutDeploy() void ProjectExplorerPluginPrivate::runProjectWithoutDeploy()
{ {
m_instance->runStartupProject(NormalRunMode, true); m_instance->runStartupProject(Constants::NORMAL_RUN_MODE, true);
} }
void ProjectExplorerPluginPrivate::runProjectContextMenu() void ProjectExplorerPluginPrivate::runProjectContextMenu()
@@ -2381,7 +2381,7 @@ void ProjectExplorerPluginPrivate::runProjectContextMenu()
Node *node = ProjectTree::currentNode(); Node *node = ProjectTree::currentNode();
ProjectNode *projectNode = node ? node->asProjectNode() : 0; ProjectNode *projectNode = node ? node->asProjectNode() : 0;
if (projectNode == ProjectTree::currentProject()->rootProjectNode() || !projectNode) { if (projectNode == ProjectTree::currentProject()->rootProjectNode() || !projectNode) {
m_instance->runProject(ProjectTree::currentProject(), NormalRunMode); m_instance->runProject(ProjectTree::currentProject(), Constants::NORMAL_RUN_MODE);
} else { } else {
QAction *act = qobject_cast<QAction *>(sender()); QAction *act = qobject_cast<QAction *>(sender());
if (!act) if (!act)
@@ -2389,7 +2389,7 @@ void ProjectExplorerPluginPrivate::runProjectContextMenu()
RunConfiguration *rc = act->data().value<RunConfiguration *>(); RunConfiguration *rc = act->data().value<RunConfiguration *>();
if (!rc) if (!rc)
return; 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) if (!pro)
return; return;
@@ -2503,13 +2503,13 @@ void ProjectExplorerPlugin::runProject(Project *pro, RunMode mode, const bool fo
runRunConfiguration(rc, mode, forceSkipDeploy); runRunConfiguration(rc, mode, forceSkipDeploy);
} }
void ProjectExplorerPlugin::runStartupProject(RunMode runMode, bool forceSkipDeploy) void ProjectExplorerPlugin::runStartupProject(Core::Id runMode, bool forceSkipDeploy)
{ {
runProject(SessionManager::startupProject(), runMode, forceSkipDeploy); runProject(SessionManager::startupProject(), runMode, forceSkipDeploy);
} }
void ProjectExplorerPlugin::runRunConfiguration(RunConfiguration *rc, void ProjectExplorerPlugin::runRunConfiguration(RunConfiguration *rc,
RunMode runMode, Core::Id runMode,
const bool forceSkipDeploy) const bool forceSkipDeploy)
{ {
if (!rc->isEnabled()) if (!rc->isEnabled())
@@ -2680,7 +2680,7 @@ void ProjectExplorerPluginPrivate::updateDeployActions()
emit m_instance->updateRunActions(); 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 (!project) {
if (whyNot) if (whyNot)
@@ -2747,7 +2747,7 @@ void ProjectExplorerPluginPrivate::slotUpdateRunActions()
{ {
Project *project = SessionManager::startupProject(); Project *project = SessionManager::startupProject();
QString whyNot; 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->setEnabled(state);
m_runAction->setToolTip(whyNot); m_runAction->setToolTip(whyNot);
m_runWithoutDeployAction->setEnabled(state); m_runWithoutDeployAction->setEnabled(state);

View File

@@ -33,6 +33,7 @@
#include "projectexplorer_export.h" #include "projectexplorer_export.h"
#include "projectexplorerconstants.h" #include "projectexplorerconstants.h"
#include "runconfiguration.h"
#include <extensionsystem/iplugin.h> #include <extensionsystem/iplugin.h>
@@ -88,7 +89,7 @@ public:
static void setProjectExplorerSettings(const Internal::ProjectExplorerSettings &pes); static void setProjectExplorerSettings(const Internal::ProjectExplorerSettings &pes);
static Internal::ProjectExplorerSettings projectExplorerSettings(); 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); static void showRunErrorMessage(const QString &errorMessage);
// internal public for FlatModel // internal public for FlatModel
@@ -97,10 +98,10 @@ public:
static bool coreAboutToClose(); static bool coreAboutToClose();
static QList<QPair<QString, QString> > recentProjects(); static QList<QPair<QString, QString> > recentProjects();
static bool canRun(Project *pro, RunMode runMode, QString *whyNot = 0); static bool canRun(Project *pro, Core::Id runMode, QString *whyNot = 0);
static void runProject(Project *pro, RunMode, const bool forceSkipDeploy = false); static void runProject(Project *pro, Core::Id, const bool forceSkipDeploy = false);
static void runStartupProject(RunMode runMode, bool forceSkipDeploy = false); static void runStartupProject(Core::Id runMode, bool forceSkipDeploy = false);
static void runRunConfiguration(RunConfiguration *rc, RunMode runMode, static void runRunConfiguration(RunConfiguration *rc, Core::Id runMode,
const bool forceSkipDeploy = false); const bool forceSkipDeploy = false);
static void addExistingFiles(FolderNode *projectNode, const QStringList &filePaths); static void addExistingFiles(FolderNode *projectNode, const QStringList &filePaths);
@@ -128,7 +129,7 @@ signals:
// or the file list of a specific project has changed. // or the file list of a specific project has changed.
void fileListChanged(); void fileListChanged();
void aboutToExecuteProject(ProjectExplorer::Project *project, RunMode runMode); void aboutToExecuteProject(ProjectExplorer::Project *project, Core::Id runMode);
void recentProjectsChanged(); void recentProjectsChanged();
void settingsChanged(); void settingsChanged();

View File

@@ -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 PAGE_ID_PREFIX[] = "PE.Wizard.Page.";
const char GENERATOR_ID_PREFIX[] = "PE.Wizard.Generator."; const char GENERATOR_ID_PREFIX[] = "PE.Wizard.Generator.";
// 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 Constants
// Run modes
enum RunMode {
NoRunMode,
NormalRunMode,
DebugRunMode,
DebugRunModeWithBreakOnMain,
QmlProfilerRunMode,
CallgrindRunMode,
MemcheckRunMode,
MemcheckWithGdbRunMode,
ClangStaticAnalyzerMode,
PerfProfilerRunMode
};
} // namespace ProjectExplorer } // namespace ProjectExplorer
#endif // PROJECTEXPLORERCONSTANTS_H #endif // PROJECTEXPLORERCONSTANTS_H

View File

@@ -51,7 +51,7 @@
#include <ApplicationServices/ApplicationServices.h> #include <ApplicationServices/ApplicationServices.h>
#endif #endif
using namespace ProjectExplorer; namespace ProjectExplorer {
/*! /*!
\class ProjectExplorer::ProcessHandle \class ProjectExplorer::ProcessHandle
@@ -515,7 +515,7 @@ IRunConfigurationAspect *IRunControlFactory::createRunConfigurationAspect(RunCon
than it needs to be. 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) : m_runMode(mode), m_runConfiguration(runConfiguration), m_outputFormatter(0)
{ {
if (runConfiguration) { if (runConfiguration) {
@@ -537,7 +537,7 @@ Utils::OutputFormatter *RunControl::outputFormatter()
return m_outputFormatter; return m_outputFormatter;
} }
RunMode RunControl::runMode() const Core::Id RunControl::runMode() const
{ {
return m_runMode; return m_runMode;
} }
@@ -663,3 +663,5 @@ void RunControl::appendMessage(const QString &msg, Utils::OutputFormat format)
{ {
emit appendMessage(this, msg, format); emit appendMessage(this, msg, format);
} }
} // namespace ProjectExplorer

View File

@@ -253,8 +253,8 @@ public:
explicit IRunControlFactory(QObject *parent = 0); explicit IRunControlFactory(QObject *parent = 0);
virtual ~IRunControlFactory(); virtual ~IRunControlFactory();
virtual bool canRun(RunConfiguration *runConfiguration, RunMode mode) const = 0; virtual bool canRun(RunConfiguration *runConfiguration, Core::Id mode) const = 0;
virtual RunControl *create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage) = 0; virtual RunControl *create(RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage) = 0;
virtual IRunConfigurationAspect *createRunConfigurationAspect(RunConfiguration *rc); virtual IRunConfigurationAspect *createRunConfigurationAspect(RunConfiguration *rc);
}; };
@@ -283,7 +283,7 @@ public:
AsynchronousStop // Stop sequence has been started AsynchronousStop // Stop sequence has been started
}; };
RunControl(RunConfiguration *runConfiguration, RunMode mode); RunControl(RunConfiguration *runConfiguration, Core::Id mode);
virtual ~RunControl(); virtual ~RunControl();
virtual void start() = 0; virtual void start() = 0;
@@ -304,7 +304,7 @@ public:
bool sameRunConfiguration(const RunControl *other) const; bool sameRunConfiguration(const RunControl *other) const;
Utils::OutputFormatter *outputFormatter(); Utils::OutputFormatter *outputFormatter();
RunMode runMode() const; Core::Id runMode() const;
public slots: public slots:
void bringApplicationToForeground(qint64 pid); void bringApplicationToForeground(qint64 pid);
@@ -328,7 +328,7 @@ protected:
private: private:
QString m_displayName; QString m_displayName;
RunMode m_runMode; Core::Id m_runMode;
QString m_icon; QString m_icon;
const QPointer<RunConfiguration> m_runConfiguration; const QPointer<RunConfiguration> m_runConfiguration;
Utils::OutputFormatter *m_outputFormatter; Utils::OutputFormatter *m_outputFormatter;

View File

@@ -406,7 +406,7 @@ private:
class PythonRunControl : public RunControl class PythonRunControl : public RunControl
{ {
public: public:
PythonRunControl(PythonRunConfiguration *runConfiguration, RunMode mode); PythonRunControl(PythonRunConfiguration *runConfiguration, Core::Id mode);
void start(); void start();
StopResult stop(); StopResult stop();
@@ -1098,16 +1098,16 @@ bool PythonProjectNode::renameFile(const QString &filePath, const QString &newFi
class PythonRunControlFactory : public IRunControlFactory class PythonRunControlFactory : public IRunControlFactory
{ {
public: public:
bool canRun(RunConfiguration *runConfiguration, RunMode mode) const; bool canRun(RunConfiguration *runConfiguration, Core::Id mode) const;
RunControl *create(RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage); 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) Q_UNUSED(errorMessage)
QTC_ASSERT(canRun(runConfiguration, mode), return 0); QTC_ASSERT(canRun(runConfiguration, mode), return 0);
@@ -1116,7 +1116,7 @@ RunControl *PythonRunControlFactory::create(RunConfiguration *runConfiguration,
// PythonRunControl // PythonRunControl
PythonRunControl::PythonRunControl(PythonRunConfiguration *rc, RunMode mode) PythonRunControl::PythonRunControl(PythonRunConfiguration *rc, Core::Id mode)
: RunControl(rc, mode), m_running(false) : RunControl(rc, mode), m_running(false)
{ {
setIcon(QLatin1String(ProjectExplorer::Constants::ICON_RUN_SMALL)); setIcon(QLatin1String(ProjectExplorer::Constants::ICON_RUN_SMALL));

View File

@@ -71,7 +71,7 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
action->setWidgetCreator(widgetCreator); action->setWidgetCreator(widgetCreator);
action->setRunControlCreator(runControlCreator); action->setRunControlCreator(runControlCreator);
action->setToolPreparer([tool] { return tool->prepareTool(); }); action->setToolPreparer([tool] { return tool->prepareTool(); });
action->setRunMode(ProjectExplorer::QmlProfilerRunMode); action->setRunMode(ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
action->setText(tr("QML Profiler")); action->setText(tr("QML Profiler"));
action->setToolTip(description); action->setToolTip(description);
action->setMenuGroup(Constants::G_ANALYZER_TOOLS); action->setMenuGroup(Constants::G_ANALYZER_TOOLS);
@@ -84,7 +84,7 @@ bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorS
action->setRunControlCreator(runControlCreator); action->setRunControlCreator(runControlCreator);
action->setCustomToolStarter([tool] { tool->startRemoteTool(); }); action->setCustomToolStarter([tool] { tool->startRemoteTool(); });
action->setToolPreparer([tool] { return tool->prepareTool(); }); 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->setText(tr("QML Profiler (External)"));
action->setToolTip(description); action->setToolTip(description);
action->setMenuGroup(Constants::G_ANALYZER_REMOTE_TOOLS); action->setMenuGroup(Constants::G_ANALYZER_REMOTE_TOOLS);

View File

@@ -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)); && (qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration));
} }
@@ -83,7 +83,7 @@ static AnalyzerStartParameters createQmlProfilerStartParameters(RunConfiguration
return sp; 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); QTC_ASSERT(canRun(runConfiguration, mode), return 0);

View File

@@ -45,10 +45,10 @@ public:
explicit QmlProfilerRunControlFactory(QObject *parent = 0); explicit QmlProfilerRunControlFactory(QObject *parent = 0);
// IRunControlFactory implementation // IRunControlFactory implementation
bool canRun(RunConfiguration *runConfiguration, ProjectExplorer::RunMode mode) const; bool canRun(RunConfiguration *runConfiguration, Core::Id mode) const;
ProjectExplorer::RunControl *create(RunConfiguration *runConfiguration, ProjectExplorer::RunControl *create(RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode, Core::Id mode,
QString *errorMessage); QString *errorMessage);
}; };

View File

@@ -486,7 +486,7 @@ void QmlProfilerTool::startRemoteTool()
sp.analyzerPort = port; sp.analyzerPort = port;
AnalyzerRunControl *rc = createRunControl(sp, 0); AnalyzerRunControl *rc = createRunControl(sp, 0);
ProjectExplorerPlugin::startRunControl(rc, QmlProfilerRunMode); ProjectExplorerPlugin::startRunControl(rc, ProjectExplorer::Constants::QML_PROFILER_RUN_MODE);
} }
void QmlProfilerTool::logState(const QString &msg) void QmlProfilerTool::logState(const QString &msg)

View File

@@ -135,7 +135,7 @@ void QnxAttachDebugSupport::attachToProcess()
} }
connect(runControl, &Debugger::DebuggerRunControl::stateChanged, connect(runControl, &Debugger::DebuggerRunControl::stateChanged,
this, &QnxAttachDebugSupport::handleDebuggerStateChanged); this, &QnxAttachDebugSupport::handleDebuggerStateChanged);
ProjectExplorer::ProjectExplorerPlugin::startRunControl(runControl, ProjectExplorer::DebugRunMode); ProjectExplorer::ProjectExplorerPlugin::startRunControl(runControl, ProjectExplorer::Constants::DEBUG_RUN_MODE);
} }
void QnxAttachDebugSupport::handleDebuggerStateChanged(Debugger::DebuggerState state) void QnxAttachDebugSupport::handleDebuggerStateChanged(Debugger::DebuggerState state)

View File

@@ -95,7 +95,7 @@ static DebuggerStartParameters createDebuggerStartParameters(QnxRunConfiguration
return params; return params;
} }
static AnalyzerStartParameters createAnalyzerStartParameters(const QnxRunConfiguration *runConfig, RunMode mode) static AnalyzerStartParameters createAnalyzerStartParameters(const QnxRunConfiguration *runConfig, Core::Id mode)
{ {
AnalyzerStartParameters params; AnalyzerStartParameters params;
Target *target = runConfig->target(); 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; return false;
}
if (!runConfiguration->isEnabled() if (!runConfiguration->isEnabled()
|| !runConfiguration->id().name().startsWith(Constants::QNX_QNX_RUNCONFIGURATION_PREFIX)) { || !runConfiguration->id().name().startsWith(Constants::QNX_QNX_RUNCONFIGURATION_PREFIX)) {
@@ -141,22 +144,22 @@ bool QnxRunControlFactory::canRun(RunConfiguration *runConfiguration, RunMode mo
if (dev.isNull()) if (dev.isNull())
return false; 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 rc->portsUsedByDebuggers() <= dev->freePorts().count();
return true; 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)); Q_ASSERT(canRun(runConfig, mode));
QnxRunConfiguration *rc = qobject_cast<QnxRunConfiguration *>(runConfig); QnxRunConfiguration *rc = qobject_cast<QnxRunConfiguration *>(runConfig);
Q_ASSERT(rc); Q_ASSERT(rc);
switch (mode) { if (mode == ProjectExplorer::Constants::NORMAL_RUN_MODE)
case NormalRunMode:
return new QnxRunControl(rc); return new QnxRunControl(rc);
case DebugRunMode: {
if (mode == ProjectExplorer::Constants::DEBUG_RUN_MODE) {
const DebuggerStartParameters params = createDebuggerStartParameters(rc); const DebuggerStartParameters params = createDebuggerStartParameters(rc);
DebuggerRunControl *runControl = createDebuggerRunControl(params, runConfig, errorMessage); DebuggerRunControl *runControl = createDebuggerRunControl(params, runConfig, errorMessage);
if (!runControl) if (!runControl)
@@ -167,21 +170,15 @@ RunControl *QnxRunControlFactory::create(RunConfiguration *runConfig, RunMode mo
return runControl; return runControl;
} }
case QmlProfilerRunMode: {
if (mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) {
const AnalyzerStartParameters params = createAnalyzerStartParameters(rc, mode); const AnalyzerStartParameters params = createAnalyzerStartParameters(rc, mode);
AnalyzerRunControl *runControl = AnalyzerManager::createRunControl(params, runConfig); AnalyzerRunControl *runControl = AnalyzerManager::createRunControl(params, runConfig);
QnxAnalyzeSupport * const analyzeSupport = new QnxAnalyzeSupport(rc, runControl); QnxAnalyzeSupport * const analyzeSupport = new QnxAnalyzeSupport(rc, runControl);
connect(runControl, SIGNAL(finished()), analyzeSupport, SLOT(handleProfilingFinished())); connect(runControl, SIGNAL(finished()), analyzeSupport, SLOT(handleProfilingFinished()));
return runControl; return runControl;
} }
case PerfProfilerRunMode:
case NoRunMode: QTC_CHECK(false);
case CallgrindRunMode:
case MemcheckRunMode:
case MemcheckWithGdbRunMode:
case ClangStaticAnalyzerMode:
case DebugRunModeWithBreakOnMain:
QTC_ASSERT(false, return 0);
}
return 0; return 0;
} }

View File

@@ -46,9 +46,9 @@ public:
explicit QnxRunControlFactory(QObject *parent = 0); explicit QnxRunControlFactory(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, QString *errorMessage); Core::Id mode, QString *errorMessage);
}; };
} // namespace Internal } // namespace Internal

View File

@@ -56,9 +56,9 @@ namespace Internal {
class RemoteLinuxAnalyzeSupportPrivate class RemoteLinuxAnalyzeSupportPrivate
{ {
public: public:
RemoteLinuxAnalyzeSupportPrivate(AnalyzerRunControl *rc, RunMode runMode) RemoteLinuxAnalyzeSupportPrivate(AnalyzerRunControl *rc, Core::Id runMode)
: runControl(rc), : runControl(rc),
qmlProfiling(runMode == QmlProfilerRunMode), qmlProfiling(runMode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE),
qmlPort(-1) qmlPort(-1)
{ {
} }
@@ -75,7 +75,7 @@ public:
using namespace Internal; using namespace Internal;
AnalyzerStartParameters RemoteLinuxAnalyzeSupport::startParameters(const RunConfiguration *runConfig, AnalyzerStartParameters RemoteLinuxAnalyzeSupport::startParameters(const RunConfiguration *runConfig,
RunMode runMode) Core::Id runMode)
{ {
AnalyzerStartParameters params; AnalyzerStartParameters params;
params.runMode = runMode; params.runMode = runMode;
@@ -88,7 +88,7 @@ AnalyzerStartParameters RemoteLinuxAnalyzeSupport::startParameters(const RunConf
} }
RemoteLinuxAnalyzeSupport::RemoteLinuxAnalyzeSupport(AbstractRemoteLinuxRunConfiguration *runConfig, RemoteLinuxAnalyzeSupport::RemoteLinuxAnalyzeSupport(AbstractRemoteLinuxRunConfiguration *runConfig,
AnalyzerRunControl *engine, RunMode runMode) AnalyzerRunControl *engine, Core::Id runMode)
: AbstractRemoteLinuxRunSupport(runConfig, engine), : AbstractRemoteLinuxRunSupport(runConfig, engine),
d(new RemoteLinuxAnalyzeSupportPrivate(engine, runMode)) d(new RemoteLinuxAnalyzeSupportPrivate(engine, runMode))
{ {

View File

@@ -53,10 +53,10 @@ class REMOTELINUX_EXPORT RemoteLinuxAnalyzeSupport : public AbstractRemoteLinuxR
Q_OBJECT Q_OBJECT
public: public:
static Analyzer::AnalyzerStartParameters startParameters(const ProjectExplorer::RunConfiguration *runConfig, static Analyzer::AnalyzerStartParameters startParameters(const ProjectExplorer::RunConfiguration *runConfig,
ProjectExplorer::RunMode runMode); Core::Id runMode);
RemoteLinuxAnalyzeSupport(AbstractRemoteLinuxRunConfiguration *runConfig, RemoteLinuxAnalyzeSupport(AbstractRemoteLinuxRunConfiguration *runConfig,
Analyzer::AnalyzerRunControl *engine, ProjectExplorer::RunMode runMode); Analyzer::AnalyzerRunControl *engine, Core::Id runMode);
~RemoteLinuxAnalyzeSupport(); ~RemoteLinuxAnalyzeSupport();
protected: protected:

View File

@@ -57,7 +57,7 @@ public:
}; };
RemoteLinuxRunControl::RemoteLinuxRunControl(RunConfiguration *rc) 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)); setIcon(QLatin1String(ProjectExplorer::Constants::ICON_RUN_SMALL));

View File

@@ -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 if (mode != ProjectExplorer::Constants::NORMAL_RUN_MODE
&& mode != QmlProfilerRunMode) { && 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;
} }
@@ -76,16 +78,16 @@ bool RemoteLinuxRunControlFactory::canRun(RunConfiguration *runConfiguration, Ru
|| id.name().startsWith(RemoteLinuxRunConfiguration::IdPrefix)); || id.name().startsWith(RemoteLinuxRunConfiguration::IdPrefix));
} }
RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, RunMode mode, RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, Core::Id mode,
QString *errorMessage) QString *errorMessage)
{ {
QTC_ASSERT(canRun(runConfig, mode), return 0); QTC_ASSERT(canRun(runConfig, mode), return 0);
switch (mode) { if (mode == ProjectExplorer::Constants::NORMAL_RUN_MODE)
case NormalRunMode:
return new RemoteLinuxRunControl(runConfig); 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()); IDevice::ConstPtr dev = DeviceKitInformation::device(runConfig->target()->kit());
if (!dev) { if (!dev) {
*errorMessage = tr("Cannot debug: Kit has no device."); *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())); connect(runControl, SIGNAL(finished()), debugSupport, SLOT(handleDebuggingFinished()));
return runControl; return runControl;
} }
case QmlProfilerRunMode: {
if (mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) {
AnalyzerStartParameters params = RemoteLinuxAnalyzeSupport::startParameters(runConfig, mode); AnalyzerStartParameters params = RemoteLinuxAnalyzeSupport::startParameters(runConfig, mode);
auto * const rc = qobject_cast<AbstractRemoteLinuxRunConfiguration *>(runConfig); auto * const rc = qobject_cast<AbstractRemoteLinuxRunConfiguration *>(runConfig);
QTC_ASSERT(rc, return 0); QTC_ASSERT(rc, return 0);
@@ -120,16 +123,8 @@ RunControl *RemoteLinuxRunControlFactory::create(RunConfiguration *runConfig, Ru
(void) new RemoteLinuxAnalyzeSupport(rc, runControl, mode); (void) new RemoteLinuxAnalyzeSupport(rc, runControl, mode);
return runControl; 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; return 0;
} }

View File

@@ -43,9 +43,9 @@ public:
~RemoteLinuxRunControlFactory(); ~RemoteLinuxRunControlFactory();
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, QString *errorMessage); Core::Id mode, QString *errorMessage);
}; };
} // namespace Internal } // namespace Internal

View File

@@ -41,6 +41,8 @@ const char CallgrindLocalActionId[] = "Callgrind.Local";
const char CallgrindRemoteActionId[] = "Callgrind.Remote"; const char CallgrindRemoteActionId[] = "Callgrind.Remote";
class ValgrindRunControl; class ValgrindRunControl;
const char CALLGRIND_RUN_MODE[] = "CallgrindTool.CallgrindRunMode";
class CallgrindToolPrivate; class CallgrindToolPrivate;
class CallgrindTool : public QObject class CallgrindTool : public QObject

View File

@@ -50,6 +50,10 @@ class Error;
} }
namespace Valgrind { namespace Valgrind {
const char MEMCHECK_RUN_MODE[] = "MemcheckTool.MemcheckRunMode";
const char MEMCHECK_WITH_GDB_RUN_MODE[] = "MemcheckTool.MemcheckWithGdbRunMode";
namespace Internal { namespace Internal {
class FrameFinder; class FrameFinder;
@@ -57,6 +61,7 @@ class MemcheckErrorView;
class MemcheckRunControl; class MemcheckRunControl;
class ValgrindBaseSettings; class ValgrindBaseSettings;
class MemcheckErrorFilterProxyModel : public QSortFilterProxyModel class MemcheckErrorFilterProxyModel : public QSortFilterProxyModel
{ {
Q_OBJECT Q_OBJECT

View File

@@ -54,7 +54,6 @@
#include <cppeditor/cppeditorconstants.h> #include <cppeditor/cppeditorconstants.h>
#include <projectexplorer/projectexplorer.h> #include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <utils/hostosinfo.h> #include <utils/hostosinfo.h>
@@ -166,7 +165,7 @@ void ValgrindPlugin::extensionsInitialized()
action->setWidgetCreator(mcWidgetCreator); action->setWidgetCreator(mcWidgetCreator);
action->setRunControlCreator(mcRunControlCreator); action->setRunControlCreator(mcRunControlCreator);
action->setToolMode(DebugMode); action->setToolMode(DebugMode);
action->setRunMode(ProjectExplorer::MemcheckRunMode); action->setRunMode(MEMCHECK_RUN_MODE);
action->setText(tr("Valgrind Memory Analyzer")); action->setText(tr("Valgrind Memory Analyzer"));
action->setToolTip(memcheckToolTip); action->setToolTip(memcheckToolTip);
action->setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS); action->setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS);
@@ -182,7 +181,7 @@ void ValgrindPlugin::extensionsInitialized()
action->setRunControlCreator(std::bind(&MemcheckWithGdbTool::createRunControl, action->setRunControlCreator(std::bind(&MemcheckWithGdbTool::createRunControl,
mcgTool, _1, _2)); mcgTool, _1, _2));
action->setToolMode(DebugMode); action->setToolMode(DebugMode);
action->setRunMode(ProjectExplorer::MemcheckWithGdbRunMode); action->setRunMode(MEMCHECK_WITH_GDB_RUN_MODE);
action->setText(tr("Valgrind Memory Analyzer with GDB")); action->setText(tr("Valgrind Memory Analyzer with GDB"));
action->setToolTip(tr("Valgrind Analyze Memory with GDB uses the " action->setToolTip(tr("Valgrind Analyze Memory with GDB uses the "
"Memcheck tool to find memory leaks.\nWhen a problem is detected, " "Memcheck tool to find memory leaks.\nWhen a problem is detected, "
@@ -197,7 +196,7 @@ void ValgrindPlugin::extensionsInitialized()
action->setWidgetCreator(cgWidgetCreator); action->setWidgetCreator(cgWidgetCreator);
action->setRunControlCreator(cgRunControlCreator); action->setRunControlCreator(cgRunControlCreator);
action->setToolMode(ReleaseMode); action->setToolMode(ReleaseMode);
action->setRunMode(CallgrindRunMode); action->setRunMode(CALLGRIND_RUN_MODE);
action->setText(tr("Valgrind Function Profiler")); action->setText(tr("Valgrind Function Profiler"));
action->setToolTip(callgrindToolTip); action->setToolTip(callgrindToolTip);
action->setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS); action->setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS);
@@ -216,7 +215,7 @@ void ValgrindPlugin::extensionsInitialized()
ValgrindRunControl *rc = mcTool->createRunControl(sp, 0); ValgrindRunControl *rc = mcTool->createRunControl(sp, 0);
QTC_ASSERT(rc, return); QTC_ASSERT(rc, return);
rc->setCustomStart(); rc->setCustomStart();
ProjectExplorerPlugin::startRunControl(rc, MemcheckRunMode); ProjectExplorerPlugin::startRunControl(rc, MEMCHECK_RUN_MODE);
}); });
action->setText(tr("Valgrind Memory Analyzer (External Remote Application)")); action->setText(tr("Valgrind Memory Analyzer (External Remote Application)"));
action->setToolTip(memcheckToolTip); action->setToolTip(memcheckToolTip);
@@ -234,7 +233,7 @@ void ValgrindPlugin::extensionsInitialized()
ValgrindRunControl *rc = cgTool->createRunControl(sp, 0); ValgrindRunControl *rc = cgTool->createRunControl(sp, 0);
QTC_ASSERT(rc, return); QTC_ASSERT(rc, return);
rc->setCustomStart(); rc->setCustomStart();
ProjectExplorerPlugin::startRunControl(rc, CallgrindRunMode); ProjectExplorerPlugin::startRunControl(rc, CALLGRIND_RUN_MODE);
}); });
action->setText(tr("Valgrind Function Profiler (External Remote Application)")); action->setText(tr("Valgrind Function Profiler (External Remote Application)"));

View File

@@ -34,6 +34,7 @@
#include <extensionsystem/iplugin.h> #include <extensionsystem/iplugin.h>
#include <analyzerbase/ianalyzertool.h> #include <analyzerbase/ianalyzertool.h>
#include <projectexplorer/projectexplorer.h>
namespace Valgrind { namespace Valgrind {
namespace Internal { namespace Internal {

View File

@@ -31,6 +31,8 @@
#include "valgrindruncontrolfactory.h" #include "valgrindruncontrolfactory.h"
#include "valgrindsettings.h" #include "valgrindsettings.h"
#include "valgrindplugin.h" #include "valgrindplugin.h"
#include "callgrindtool.h"
#include "memchecktool.h"
#include <analyzerbase/ianalyzertool.h> #include <analyzerbase/ianalyzertool.h>
#include <analyzerbase/analyzermanager.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); 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); Q_UNUSED(errorMessage);

View File

@@ -45,10 +45,10 @@ public:
explicit ValgrindRunControlFactory(QObject *parent = 0); explicit ValgrindRunControlFactory(QObject *parent = 0);
// IRunControlFactory implementation // IRunControlFactory implementation
bool canRun(RunConfiguration *runConfiguration, ProjectExplorer::RunMode mode) const; bool canRun(RunConfiguration *runConfiguration, Core::Id mode) const;
ProjectExplorer::RunControl *create(RunConfiguration *runConfiguration, ProjectExplorer::RunControl *create(RunConfiguration *runConfiguration,
ProjectExplorer::RunMode mode, Core::Id mode,
QString *errorMessage); QString *errorMessage);
ProjectExplorer::IRunConfigurationAspect *createRunConfigurationAspect(ProjectExplorer::RunConfiguration *rc); ProjectExplorer::IRunConfigurationAspect *createRunConfigurationAspect(ProjectExplorer::RunConfiguration *rc);
}; };

View File

@@ -68,7 +68,7 @@ void WinRtDebugSupport::finish()
} }
RunControl *WinRtDebugSupport::createDebugRunControl(WinRtRunConfiguration *runConfig, RunControl *WinRtDebugSupport::createDebugRunControl(WinRtRunConfiguration *runConfig,
RunMode mode, Core::Id mode,
QString *errorMessage) QString *errorMessage)
{ {
// FIXME: This is just working for local debugging; // FIXME: This is just working for local debugging;

View File

@@ -47,7 +47,7 @@ class WinRtDebugSupport : public QObject
Q_OBJECT Q_OBJECT
public: public:
static ProjectExplorer::RunControl *createDebugRunControl(WinRtRunConfiguration *runConfig, static ProjectExplorer::RunControl *createDebugRunControl(WinRtRunConfiguration *runConfig,
ProjectExplorer::RunMode mode, Core::Id mode,
QString *errorMessage); QString *errorMessage);
~WinRtDebugSupport(); ~WinRtDebugSupport();

View File

@@ -48,13 +48,13 @@
using ProjectExplorer::DeviceKitInformation; using ProjectExplorer::DeviceKitInformation;
using ProjectExplorer::IDevice; using ProjectExplorer::IDevice;
using ProjectExplorer::RunControl; using ProjectExplorer::RunControl;
using ProjectExplorer::RunMode; using Core::Id;
using ProjectExplorer::Target; using ProjectExplorer::Target;
namespace WinRt { namespace WinRt {
namespace Internal { namespace Internal {
WinRtRunControl::WinRtRunControl(WinRtRunConfiguration *runConfiguration, RunMode mode) WinRtRunControl::WinRtRunControl(WinRtRunConfiguration *runConfiguration, Core::Id mode)
: RunControl(runConfiguration, mode) : RunControl(runConfiguration, mode)
, m_runConfiguration(runConfiguration) , m_runConfiguration(runConfiguration)
, m_state(StoppedState) , m_state(StoppedState)

View File

@@ -54,7 +54,7 @@ class WinRtRunControl : public ProjectExplorer::RunControl
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit WinRtRunControl(WinRtRunConfiguration *runConfiguration, ProjectExplorer::RunMode mode); explicit WinRtRunControl(WinRtRunConfiguration *runConfiguration, Core::Id mode);
void start(); void start();
StopResult stop(); StopResult stop();

View File

@@ -137,7 +137,7 @@ WinRtRunControlFactory::WinRtRunControlFactory()
} }
bool WinRtRunControlFactory::canRun(RunConfiguration *runConfiguration, bool WinRtRunControlFactory::canRun(RunConfiguration *runConfiguration,
RunMode mode) const Core::Id mode) const
{ {
if (!runConfiguration) if (!runConfiguration)
return false; return false;
@@ -145,35 +145,32 @@ bool WinRtRunControlFactory::canRun(RunConfiguration *runConfiguration,
if (!device) if (!device)
return false; return false;
switch (mode) { if (mode == ProjectExplorer::Constants::DEBUG_RUN_MODE
case DebugRunMode: || mode == ProjectExplorer::Constants::DEBUG_RUN_MODE_WITH_BREAK_ON_MAIN) {
case DebugRunModeWithBreakOnMain:
if (device->type() != Constants::WINRT_DEVICE_TYPE_LOCAL) if (device->type() != Constants::WINRT_DEVICE_TYPE_LOCAL)
return false; return false;
// fall through
case NormalRunMode:
return qobject_cast<WinRtRunConfiguration *>(runConfiguration); 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( RunControl *WinRtRunControlFactory::create(
RunConfiguration *runConfiguration, RunMode mode, QString *errorMessage) RunConfiguration *runConfiguration, Core::Id mode, QString *errorMessage)
{ {
WinRtRunConfiguration *rc = qobject_cast<WinRtRunConfiguration *>(runConfiguration); WinRtRunConfiguration *rc = qobject_cast<WinRtRunConfiguration *>(runConfiguration);
QTC_ASSERT(rc, return 0); QTC_ASSERT(rc, return 0);
switch (mode) { if (mode == ProjectExplorer::Constants::NORMAL_RUN_MODE)
case NormalRunMode:
return new WinRtRunControl(rc, 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); return WinRtDebugSupport::createDebugRunControl(rc, mode, errorMessage);
default:
break; *errorMessage = tr("Unsupported run mode %1.").arg(mode.toString());
}
*errorMessage = tr("Unsupported run mode %1.").arg(mode);
return 0; return 0;
} }

View File

@@ -64,9 +64,9 @@ class WinRtRunControlFactory : public ProjectExplorer::IRunControlFactory
public: public:
WinRtRunControlFactory(); WinRtRunControlFactory();
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, QString *errorMessage); Core::Id mode, QString *errorMessage);
QString displayName() const; QString displayName() const;
}; };