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

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

View File

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

View File

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

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

View File

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

View File

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

View File

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