forked from qt-creator/qt-creator
Analyzer: Move extensionInitialized() out of IAnalyzerTool
Change-Id: Idd0913ba798a04f65711591dee14cbb714440cbf Reviewed-by: Aurindam Jana <aurindam.jana@digia.com>
This commit is contained in:
@@ -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)
|
||||
|
@@ -63,7 +63,6 @@ public:
|
||||
explicit AnalyzerManager(QObject *parent);
|
||||
~AnalyzerManager();
|
||||
|
||||
static void extensionsInitialized();
|
||||
static void shutdown();
|
||||
|
||||
// Register a tool for a given start mode.
|
||||
|
@@ -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();
|
||||
|
@@ -48,7 +48,7 @@ public:
|
||||
virtual ~AnalyzerPlugin();
|
||||
|
||||
bool initialize(const QStringList &arguments, QString *errorString);
|
||||
void extensionsInitialized();
|
||||
void extensionsInitialized() {}
|
||||
|
||||
ShutdownFlag aboutToShutdown();
|
||||
};
|
||||
|
@@ -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.
|
||||
|
@@ -51,16 +51,11 @@
|
||||
#include <analyzerbase/analyzerutils.h>
|
||||
#include <analyzerbase/analyzerconstants.h>
|
||||
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/icontext.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <cplusplus/LookupContext.h>
|
||||
#include <cplusplus/Overview.h>
|
||||
#include <cppeditor/cppeditorconstants.h>
|
||||
#include <extensionsystem/iplugin.h>
|
||||
#include <texteditor/itexteditor.h>
|
||||
|
||||
@@ -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();
|
||||
|
@@ -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;
|
||||
};
|
||||
|
@@ -33,13 +33,20 @@
|
||||
#include "callgrindtool.h"
|
||||
#include "memchecktool.h"
|
||||
#include "valgrindruncontrolfactory.h"
|
||||
#include "valgrindsettings.h"
|
||||
|
||||
#include <analyzerbase/analyzermanager.h>
|
||||
#include <analyzerbase/analyzersettings.h>
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/command.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
#include <coreplugin/icontext.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <valgrind/valgrindsettings.h>
|
||||
#include <cppeditor/cppeditorconstants.h>
|
||||
|
||||
#include <utils/hostosinfo.h>
|
||||
|
||||
@@ -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
|
||||
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user