forked from qt-creator/qt-creator
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user