diff options
author | hjk <hjk@qt.io> | 2017-04-12 10:06:41 +0200 |
---|---|---|
committer | hjk <hjk@qt.io> | 2017-04-24 09:52:48 +0000 |
commit | e063ca68d0dbb13e3875b86251c19de9fe07c7db (patch) | |
tree | ece6f3bfbc589f9ff12e025c10771d5da98867d4 /src/plugins/valgrind/memchecktool.cpp | |
parent | e821b98c11ce4eb0db7eb34fdfef35b5c6675a83 (diff) |
Debugger: Dissolve Debugger::ActionDescription
ActionDescription was a horizontal layer of convenience functionality
covering (only) ex-AnalyzerBase based RunControl start scenarios
and gets in the way of target/tool orthogonalization.
So continue the path chosen with the removal of AnalyzerRunControl:
Remove ActionDescription by inlining into user code, then orthogonalize
tool-by-tool, then generalize again.
Change-Id: Ib597df3f4ad7b06bef06644458fa13ddca53afdb
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/plugins/valgrind/memchecktool.cpp')
-rw-r--r-- | src/plugins/valgrind/memchecktool.cpp | 77 |
1 files changed, 53 insertions, 24 deletions
diff --git a/src/plugins/valgrind/memchecktool.cpp b/src/plugins/valgrind/memchecktool.cpp index 6b40384dac..aab1a8c24e 100644 --- a/src/plugins/valgrind/memchecktool.cpp +++ b/src/plugins/valgrind/memchecktool.cpp @@ -58,6 +58,7 @@ #include <projectexplorer/buildconfiguration.h> #include <coreplugin/actionmanager/actioncontainer.h> +#include <coreplugin/actionmanager/actioncontainer.h> #include <coreplugin/actionmanager/actionmanager.h> #include <coreplugin/actionmanager/command.h> #include <coreplugin/editormanager/editormanager.h> @@ -87,6 +88,7 @@ #include <QString> #include <QToolButton> +using namespace Core; using namespace Debugger; using namespace ProjectExplorer; using namespace Utils; @@ -390,37 +392,66 @@ MemcheckTool::MemcheckTool(QObject *parent) connect(m_filterMenu, &QMenu::triggered, this, &MemcheckTool::updateErrorFilter); filterButton->setMenu(m_filterMenu); - ActionDescription desc; - desc.setToolTip(tr("Valgrind Analyze Memory uses the " - "Memcheck tool to find memory leaks.")); + ActionContainer *menu = ActionManager::actionContainer(Debugger::Constants::M_DEBUG_ANALYZER); + QString toolTip = tr("Valgrind Analyze Memory uses the Memcheck tool to find memory leaks."); if (!Utils::HostOsInfo::isWindowsHost()) { - desc.setText(tr("Valgrind Memory Analyzer")); - desc.setPerspectiveId(MemcheckPerspectiveId); - desc.setRunControlCreator(std::bind(&MemcheckTool::createRunControl, this, _1, _2)); - desc.setToolMode(DebugMode); - desc.setRunMode(MEMCHECK_RUN_MODE); - desc.setMenuGroup(Debugger::Constants::G_ANALYZER_TOOLS); - Debugger::registerAction("Memcheck.Local", desc, m_startAction); - - desc.setText(tr("Valgrind Memory Analyzer with GDB")); - desc.setToolTip(tr("Valgrind Analyze Memory with GDB uses the " + Debugger::registerAction(MEMCHECK_RUN_MODE, std::bind(&MemcheckTool::createRunControl, this, _1, _2)); + action = new QAction(this); + action->setText(tr("Valgrind Memory Analyzer")); + action->setToolTip(toolTip); + menu->addAction(ActionManager::registerAction(action, "Memcheck.Local"), + Debugger::Constants::G_ANALYZER_TOOLS); + QObject::connect(action, &QAction::triggered, this, [action] { + if (!Debugger::wantRunTool(DebugMode, action->text())) + return; + TaskHub::clearTasks(Debugger::Constants::ANALYZERTASK_ID); + Debugger::selectPerspective(MemcheckPerspectiveId); + ProjectExplorerPlugin::runStartupProject(MEMCHECK_RUN_MODE); + }); + QObject::connect(m_startAction, &QAction::triggered, action, &QAction::triggered); + QObject::connect(m_startAction, &QAction::changed, action, [action, this] { + action->setEnabled(m_startAction->isEnabled()); + }); + + Debugger::registerAction(MEMCHECK_WITH_GDB_RUN_MODE, std::bind(&MemcheckTool::createRunControl, this, _1, _2)); + action = new QAction(this); + 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, " "the application is interrupted and can be debugged.")); - desc.setPerspectiveId(MemcheckPerspectiveId); - desc.setRunControlCreator(std::bind(&MemcheckTool::createRunControl, this, _1, _2)); - desc.setToolMode(DebugMode); - desc.setRunMode(MEMCHECK_WITH_GDB_RUN_MODE); - desc.setMenuGroup(Debugger::Constants::G_ANALYZER_TOOLS); - Debugger::registerAction("MemcheckWithGdb.Local", desc, m_startWithGdbAction); + menu->addAction(ActionManager::registerAction(action, "MemcheckWithGdb.Local"), + Debugger::Constants::G_ANALYZER_TOOLS); + QObject::connect(action, &QAction::triggered, this, [action] { + if (!Debugger::wantRunTool(DebugMode, action->text())) + return; + TaskHub::clearTasks(Debugger::Constants::ANALYZERTASK_ID); + Debugger::selectPerspective(MemcheckPerspectiveId); + ProjectExplorerPlugin::runStartupProject(MEMCHECK_WITH_GDB_RUN_MODE); + }); + QObject::connect(m_startWithGdbAction, &QAction::triggered, action, &QAction::triggered); + QObject::connect(m_startWithGdbAction, &QAction::changed, action, [action, this] { + action->setEnabled(m_startWithGdbAction->isEnabled()); + }); } - desc.setText(tr("Valgrind Memory Analyzer (External Application)")); - desc.setPerspectiveId(MemcheckPerspectiveId); - desc.setCustomToolStarter([this](ProjectExplorer::RunConfiguration *runConfig) { + Debugger::registerAction(MEMCHECK_RUN_MODE, std::bind(&MemcheckTool::createRunControl, this, _1, _2)); + action = new QAction(this); + action->setText(tr("Valgrind Memory Analyzer (External Application)")); + action->setToolTip(toolTip); + menu->addAction(ActionManager::registerAction(action, "Memcheck.Remote"), + Debugger::Constants::G_ANALYZER_REMOTE_TOOLS); + QObject::connect(action, &QAction::triggered, this, [this, action] { + RunConfiguration *runConfig = startupRunConfiguration(); + if (!runConfig) { + showCannotStartDialog(action->text()); + return; + } StartRemoteDialog dlg; if (dlg.exec() != QDialog::Accepted) return; + TaskHub::clearTasks(Debugger::Constants::ANALYZERTASK_ID); + Debugger::selectPerspective(MemcheckPerspectiveId); RunControl *rc = createRunControl(runConfig, MEMCHECK_RUN_MODE); QTC_ASSERT(rc, return); const auto runnable = dlg.runnable(); @@ -431,8 +462,6 @@ MemcheckTool::MemcheckTool(QObject *parent) rc->setDisplayName(runnable.executable); ProjectExplorerPlugin::startRunControl(rc); }); - desc.setMenuGroup(Debugger::Constants::G_ANALYZER_REMOTE_TOOLS); - Debugger::registerAction("Memcheck.Remote", desc); ToolbarDescription toolbar; toolbar.addAction(m_startAction); |