summaryrefslogtreecommitdiff
path: root/src/plugins/valgrind
diff options
context:
space:
mode:
authorBogDan Vatra <bogdan@kde.org>2015-06-29 10:36:29 +0300
committerBogDan Vatra <bogdan@kde.org>2015-06-30 06:20:54 +0000
commit2182ded57be0bd91ab4459e622c2ac8fbef90e65 (patch)
tree1b3941c056e883b5eaa8578b26f7bc26cbf2abe9 /src/plugins/valgrind
parent7743664957f3a9e857d72530e475d13844bd4037 (diff)
downloadqt-creator-2182ded57be0bd91ab4459e622c2ac8fbef90e65.tar.gz
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>
Diffstat (limited to 'src/plugins/valgrind')
-rw-r--r--src/plugins/valgrind/callgrindtool.h2
-rw-r--r--src/plugins/valgrind/memchecktool.h5
-rw-r--r--src/plugins/valgrind/valgrindplugin.cpp11
-rw-r--r--src/plugins/valgrind/valgrindplugin.h1
-rw-r--r--src/plugins/valgrind/valgrindruncontrolfactory.cpp8
-rw-r--r--src/plugins/valgrind/valgrindruncontrolfactory.h4
6 files changed, 20 insertions, 11 deletions
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);
};