diff --git a/src/plugins/analyzerbase/analyzermanager.cpp b/src/plugins/analyzerbase/analyzermanager.cpp index 189afb35609..58a06e7ad60 100644 --- a/src/plugins/analyzerbase/analyzermanager.cpp +++ b/src/plugins/analyzerbase/analyzermanager.cpp @@ -624,12 +624,6 @@ AnalyzerManager::~AnalyzerManager() d = 0; } -void AnalyzerManager::extensionsInitialized() -{ - foreach (IAnalyzerTool *tool, d->m_tools) - tool->extensionsInitialized(); -} - void AnalyzerManager::shutdown() { if (d->m_currentAction) diff --git a/src/plugins/analyzerbase/analyzermanager.h b/src/plugins/analyzerbase/analyzermanager.h index 8247cedaf71..7ea42c0b183 100644 --- a/src/plugins/analyzerbase/analyzermanager.h +++ b/src/plugins/analyzerbase/analyzermanager.h @@ -63,7 +63,6 @@ public: explicit AnalyzerManager(QObject *parent); ~AnalyzerManager(); - static void extensionsInitialized(); static void shutdown(); // Register a tool for a given start mode. diff --git a/src/plugins/analyzerbase/analyzerplugin.cpp b/src/plugins/analyzerbase/analyzerplugin.cpp index 132823810e4..c349144ded4 100644 --- a/src/plugins/analyzerbase/analyzerplugin.cpp +++ b/src/plugins/analyzerbase/analyzerplugin.cpp @@ -72,11 +72,6 @@ bool AnalyzerPlugin::initialize(const QStringList &arguments, QString *errorStri return true; } -void AnalyzerPlugin::extensionsInitialized() -{ - AnalyzerManager::extensionsInitialized(); -} - ExtensionSystem::IPlugin::ShutdownFlag AnalyzerPlugin::aboutToShutdown() { AnalyzerManager::shutdown(); diff --git a/src/plugins/analyzerbase/analyzerplugin.h b/src/plugins/analyzerbase/analyzerplugin.h index add489b73a7..2afaf12df14 100644 --- a/src/plugins/analyzerbase/analyzerplugin.h +++ b/src/plugins/analyzerbase/analyzerplugin.h @@ -48,7 +48,7 @@ public: virtual ~AnalyzerPlugin(); bool initialize(const QStringList &arguments, QString *errorString); - void extensionsInitialized(); + void extensionsInitialized() {} ShutdownFlag aboutToShutdown(); }; diff --git a/src/plugins/analyzerbase/ianalyzertool.h b/src/plugins/analyzerbase/ianalyzertool.h index f9ac4bf9328..ae452128200 100644 --- a/src/plugins/analyzerbase/ianalyzertool.h +++ b/src/plugins/analyzerbase/ianalyzertool.h @@ -86,9 +86,6 @@ public: }; virtual ToolMode toolMode() const = 0; - /// This gets called after all analyzation tools where initialized. - virtual void extensionsInitialized() {} - /// Creates all widgets used by the tool. /// Returns a control widget which will be shown in the status bar when /// this tool is selected. Must be non-zero. diff --git a/src/plugins/valgrind/callgrindtool.cpp b/src/plugins/valgrind/callgrindtool.cpp index 48f77fed32c..2359da63070 100644 --- a/src/plugins/valgrind/callgrindtool.cpp +++ b/src/plugins/valgrind/callgrindtool.cpp @@ -51,16 +51,11 @@ #include #include -#include -#include -#include #include -#include #include #include #include -#include #include #include @@ -207,7 +202,6 @@ public: QAction *m_dumpAction; QAction *m_resetAction; QAction *m_pauseAction; - QAction *m_showCostsOfFunctionAction; QString m_toggleCollectFunction; }; @@ -236,7 +230,6 @@ CallgrindToolPrivate::CallgrindToolPrivate(CallgrindTool *parent) , m_dumpAction(0) , m_resetAction(0) , m_pauseAction(0) - , m_showCostsOfFunctionAction(0) { m_updateTimer->setInterval(200); m_updateTimer->setSingleShot(true); @@ -520,30 +513,6 @@ IAnalyzerTool::ToolMode CallgrindTool::toolMode() const return ReleaseMode; } -void CallgrindTool::extensionsInitialized() -{ - Core::Context analyzerContext = Core::Context(Analyzer::Constants::C_ANALYZEMODE); - - // check if there is a CppEditor context menu, if true, add our own context menu actions - if (Core::ActionContainer *editorContextMenu = - Core::ActionManager::actionContainer(CppEditor::Constants::M_CONTEXT)) { - QAction *action = 0; - Core::Command *cmd = 0; - - editorContextMenu->addSeparator(analyzerContext); - - action = new QAction(tr("Profile Costs of this Function and its Callees"), this); - action->setIcon(QIcon(QLatin1String(Analyzer::Constants::ANALYZER_CONTROL_START_ICON))); - connect(action, SIGNAL(triggered()), d, SLOT(handleShowCostsOfFunction())); - cmd = Core::ActionManager::registerAction(action, "Analyzer.Callgrind.ShowCostsOfFunction", - analyzerContext); - editorContextMenu->addAction(cmd); - cmd->setAttribute(Core::Command::CA_Hide); - cmd->setAttribute(Core::Command::CA_NonConfigurable); - d->m_showCostsOfFunctionAction = action; - } -} - AnalyzerRunControl *CallgrindTool::createRunControl(const AnalyzerStartParameters &sp, RunConfiguration *runConfiguration) { @@ -595,6 +564,11 @@ void CallgrindTool::startTool(StartMode mode) d->setBusyCursor(true); } +void CallgrindTool::handleShowCostsOfFunction() +{ + d->handleShowCostsOfFunction(); +} + QWidget *CallgrindTool::createWidgets() { return d->createWidgets(); diff --git a/src/plugins/valgrind/callgrindtool.h b/src/plugins/valgrind/callgrindtool.h index 3afb90a28ce..a3d0b1424c4 100644 --- a/src/plugins/valgrind/callgrindtool.h +++ b/src/plugins/valgrind/callgrindtool.h @@ -48,14 +48,15 @@ public: ProjectExplorer::RunMode runMode() const; ToolMode toolMode() const; - void extensionsInitialized(); - Analyzer::AnalyzerRunControl *createRunControl(const Analyzer::AnalyzerStartParameters &sp, ProjectExplorer::RunConfiguration *runConfiguration = 0); QWidget *createWidgets(); void startTool(Analyzer::StartMode mode); +public slots: + void handleShowCostsOfFunction(); + private: CallgrindToolPrivate *d; }; diff --git a/src/plugins/valgrind/valgrindplugin.cpp b/src/plugins/valgrind/valgrindplugin.cpp index 8b4a4499a49..c2711b46f35 100644 --- a/src/plugins/valgrind/valgrindplugin.cpp +++ b/src/plugins/valgrind/valgrindplugin.cpp @@ -33,13 +33,20 @@ #include "callgrindtool.h" #include "memchecktool.h" #include "valgrindruncontrolfactory.h" +#include "valgrindsettings.h" #include #include #include +#include +#include +#include +#include +#include +#include -#include +#include #include @@ -95,8 +102,9 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *) addAutoReleasedObject(new ValgrindOptionsPage()); - IAnalyzerTool *memcheckTool = new MemcheckTool(this); - IAnalyzerTool *callgrindTool = new CallgrindTool(this); + m_memcheckTool = new MemcheckTool(this); + m_callgrindTool = new CallgrindTool(this); + ValgrindAction *action = 0; QString callgrindToolTip = tr("Valgrind Function Profile uses the " @@ -108,7 +116,7 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *) if (!Utils::HostOsInfo::isWindowsHost()) { action = new ValgrindAction; action->setId("Memcheck.Local"); - action->setTool(memcheckTool); + action->setTool(m_memcheckTool); action->setText(tr("Valgrind Memory Analyzer")); action->setToolTip(memcheckToolTip); action->setMenuGroup(Constants::G_ANALYZER_TOOLS); @@ -118,7 +126,7 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *) action = new ValgrindAction; action->setId("Callgrind.Local"); - action->setTool(callgrindTool); + action->setTool(m_callgrindTool); action->setText(tr("Valgrind Function Profiler")); action->setToolTip(callgrindToolTip); action->setMenuGroup(Constants::G_ANALYZER_TOOLS); @@ -129,7 +137,7 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *) action = new ValgrindAction; action->setId("Memcheck.Remote"); - action->setTool(memcheckTool); + action->setTool(m_memcheckTool); action->setText(tr("Valgrind Memory Analyzer (Remote)")); action->setToolTip(memcheckToolTip); action->setMenuGroup(Constants::G_ANALYZER_REMOTE_TOOLS); @@ -138,7 +146,7 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *) action = new ValgrindAction; action->setId("Callgrind.Remote"); - action->setTool(callgrindTool); + action->setTool(m_callgrindTool); action->setText(tr("Valgrind Function Profiler (Remote)")); action->setToolTip(callgrindToolTip); action->setMenuGroup(Constants::G_ANALYZER_REMOTE_TOOLS); @@ -155,6 +163,27 @@ ValgrindGlobalSettings *ValgrindPlugin::globalSettings() return theGlobalSettings; } +void ValgrindPlugin::extensionsInitialized() +{ + using namespace Core; + + // If there is a CppEditor context menu add our own context menu actions. + if (ActionContainer *editorContextMenu = + ActionManager::actionContainer(CppEditor::Constants::M_CONTEXT)) { + Context analyzerContext = Context(Analyzer::Constants::C_ANALYZEMODE); + editorContextMenu->addSeparator(analyzerContext); + + QAction *action = new QAction(tr("Profile Costs of this Function and its Callees"), this); + action->setIcon(QIcon(QLatin1String(Analyzer::Constants::ANALYZER_CONTROL_START_ICON))); + connect(action, SIGNAL(triggered()), m_callgrindTool, SLOT(handleShowCostsOfFunction())); + Command *cmd = ActionManager::registerAction(action, "Analyzer.Callgrind.ShowCostsOfFunction", + analyzerContext); + editorContextMenu->addAction(cmd); + cmd->setAttribute(Command::CA_Hide); + cmd->setAttribute(Command::CA_NonConfigurable); + } +} + } // namespace Internal } // namespace Valgrind diff --git a/src/plugins/valgrind/valgrindplugin.h b/src/plugins/valgrind/valgrindplugin.h index e5dd4b1056d..0ee4138c0a2 100644 --- a/src/plugins/valgrind/valgrindplugin.h +++ b/src/plugins/valgrind/valgrindplugin.h @@ -38,6 +38,8 @@ namespace Valgrind { namespace Internal { class ValgrindGlobalSettings; +class MemcheckTool; +class CallgrindTool; class ValgrindPlugin : public ExtensionSystem::IPlugin { @@ -49,9 +51,13 @@ public: ~ValgrindPlugin(); bool initialize(const QStringList &arguments, QString *errorString); - void extensionsInitialized() {} + void extensionsInitialized(); static ValgrindGlobalSettings *globalSettings(); + +private: + MemcheckTool *m_memcheckTool; + CallgrindTool *m_callgrindTool; }; } // namespace Internal