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

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

View File

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

View File

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

View File

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

View File

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

View File

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