forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -57,6 +57,7 @@
|
||||
#include <projectexplorer/session.h>
|
||||
#include <projectexplorer/buildconfiguration.h>
|
||||
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
#include <coreplugin/actionmanager/actionmanager.h>
|
||||
#include <coreplugin/actionmanager/command.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);
|
||||
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());
|
||||
});
|
||||
|
||||
desc.setText(tr("Valgrind Memory Analyzer with GDB"));
|
||||
desc.setToolTip(tr("Valgrind Analyze Memory with GDB uses the "
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user