From 54ce123a260fd487514d61eb5e0a4db0163920e0 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 19 Feb 2015 17:20:38 +0100 Subject: [PATCH] ProjectExplorer: Add runStartupProject() convenience function The usage pattern seems to be used often enough to justify a function. Change-Id: Iecdeb2b42879f419154902e685d0d13e8cae8b33 Reviewed-by: Christian Stenger Reviewed-by: Daniel Teske --- src/plugins/debugger/debuggerplugin.cpp | 26 +++---------------- .../projectexplorer/projectexplorer.cpp | 9 +++++-- src/plugins/projectexplorer/projectexplorer.h | 1 + src/plugins/qmlprofiler/qmlprofilertool.cpp | 3 +-- src/plugins/valgrind/callgrindtool.cpp | 3 +-- src/plugins/valgrind/memchecktool.cpp | 12 +++------ 6 files changed, 18 insertions(+), 36 deletions(-) diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index b0a4a3d35ae..b3f31bc1015 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -709,9 +709,6 @@ public: void showSettingsDialog(); void updateDebugWithoutDeployMenu(); - void debugProject(); - void debugProjectWithoutDeploy(); - void debugProjectBreakMain(); void startAndDebugApplication(); void startRemoteCdbSession(); void startRemoteServer(); @@ -819,7 +816,7 @@ public slots: void handleExecStep() { if (currentEngine()->state() == DebuggerNotReady) { - debugProjectBreakMain(); + ProjectExplorerPlugin::runStartupProject(DebugRunModeWithBreakOnMain); } else { currentEngine()->resetLocation(); if (boolSetting(OperateByInstruction)) @@ -832,7 +829,7 @@ public slots: void handleExecNext() { if (currentEngine()->state() == DebuggerNotReady) { - debugProjectBreakMain(); + ProjectExplorerPlugin::runStartupProject(DebugRunModeWithBreakOnMain); } else { currentEngine()->resetLocation(); if (boolSetting(OperateByInstruction)) @@ -1327,21 +1324,6 @@ void DebuggerPluginPrivate::onCurrentProjectChanged(Project *project) setProxyAction(m_visibleStartAction, Id(Constants::DEBUG)); } -void DebuggerPluginPrivate::debugProject() -{ - ProjectExplorerPlugin::runProject(SessionManager::startupProject(), DebugRunMode); -} - -void DebuggerPluginPrivate::debugProjectWithoutDeploy() -{ - ProjectExplorerPlugin::runProject(SessionManager::startupProject(), DebugRunMode, true); -} - -void DebuggerPluginPrivate::debugProjectBreakMain() -{ - ProjectExplorerPlugin::runProject(SessionManager::startupProject(), DebugRunModeWithBreakOnMain); -} - void DebuggerPluginPrivate::startAndDebugApplication() { DebuggerStartParameters sp; @@ -2652,11 +2634,11 @@ void DebuggerPluginPrivate::extensionsInitialized() debuggerIcon.addFile(QLatin1String(":/projectexplorer/images/debugger_start.png")); act->setIcon(debuggerIcon); act->setText(tr("Start Debugging")); - connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::debugProject); + connect(act, &QAction::triggered, [] { ProjectExplorerPlugin::runStartupProject(DebugRunMode); }); act = m_debugWithoutDeployAction = new QAction(this); act->setText(tr("Start Debugging Without Deployment")); - connect(act, &QAction::triggered, this, &DebuggerPluginPrivate::debugProjectWithoutDeploy); + connect(act, &QAction::triggered, [] { ProjectExplorerPlugin::runStartupProject(DebugRunMode, true); }); act = m_startAndDebugApplicationAction = new QAction(this); act->setText(tr("Start and Debug External Application...")); diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 2d928926d84..0acfb9cd3a0 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -2256,12 +2256,12 @@ void ProjectExplorerPlugin::cleanSession() void ProjectExplorerPlugin::runProject() { - runProject(SessionManager::startupProject(), NormalRunMode); + runStartupProject(NormalRunMode); } void ProjectExplorerPlugin::runProjectWithoutDeploy() { - runProject(SessionManager::startupProject(), NormalRunMode, true); + runStartupProject(NormalRunMode, true); } void ProjectExplorerPlugin::runProjectContextMenu() @@ -2390,6 +2390,11 @@ void ProjectExplorerPlugin::runProject(Project *pro, RunMode mode, const bool fo runRunConfiguration(rc, mode, forceSkipDeploy); } +void ProjectExplorerPlugin::runStartupProject(RunMode runMode, bool forceSkipDeploy) +{ + runProject(SessionManager::startupProject(), runMode, forceSkipDeploy); +} + void ProjectExplorerPlugin::runRunConfiguration(RunConfiguration *rc, RunMode runMode, const bool forceSkipDeploy) diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index b1c17c633e5..d80f4477b57 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -99,6 +99,7 @@ public: static bool canRun(Project *pro, RunMode runMode, QString *whyNot = 0); static void runProject(Project *pro, RunMode, const bool forceSkipDeploy = false); + static void runStartupProject(RunMode runMode, bool forceSkipDeploy = false); static void runRunConfiguration(RunConfiguration *rc, RunMode runMode, const bool forceSkipDeploy = false); diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index c03053fde1b..33c1af157dd 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -498,8 +498,7 @@ void QmlProfilerTool::startLocalTool() AnalyzerManager::showMode(); // ### not sure if we're supposed to check if the RunConFiguration isEnabled - Project *pro = SessionManager::startupProject(); - ProjectExplorerPlugin::runProject(pro, QmlProfilerRunMode); + ProjectExplorerPlugin::runStartupProject(QmlProfilerRunMode); } void QmlProfilerTool::startRemoteTool() diff --git a/src/plugins/valgrind/callgrindtool.cpp b/src/plugins/valgrind/callgrindtool.cpp index 08410e96293..27771bafc51 100644 --- a/src/plugins/valgrind/callgrindtool.cpp +++ b/src/plugins/valgrind/callgrindtool.cpp @@ -560,8 +560,7 @@ AnalyzerRunControl *CallgrindToolPrivate::createRunControl(const AnalyzerStartPa void CallgrindTool::startLocalTool() { if (checkForLocalStart(ReleaseMode)) { - Project *pro = SessionManager::startupProject(); - ProjectExplorerPlugin::runProject(pro, CallgrindRunMode); + ProjectExplorerPlugin::runStartupProject(CallgrindRunMode); d->setBusyCursor(true); } } diff --git a/src/plugins/valgrind/memchecktool.cpp b/src/plugins/valgrind/memchecktool.cpp index 86113d8e3bb..4365c077dfc 100644 --- a/src/plugins/valgrind/memchecktool.cpp +++ b/src/plugins/valgrind/memchecktool.cpp @@ -599,10 +599,8 @@ void MemcheckTool::setBusyCursor(bool busy) void MemcheckTool::startLocalTool() { - if (checkForLocalStart(DebugMode)) { - Project *pro = SessionManager::startupProject(); - ProjectExplorerPlugin::runProject(pro, MemcheckRunMode); - } + if (checkForLocalStart(DebugMode)) + ProjectExplorerPlugin::runStartupProject(MemcheckRunMode); } void MemcheckTool::startRemoteTool() @@ -622,10 +620,8 @@ MemcheckWithGdbTool::MemcheckWithGdbTool(QObject *parent) : void MemcheckWithGdbTool::startLocalTool() { - if (checkForLocalStart(DebugMode)) { - Project *pro = SessionManager::startupProject(); - ProjectExplorerPlugin::runProject(pro, MemcheckWithGdbRunMode); - } + if (checkForLocalStart(DebugMode)) + ProjectExplorerPlugin::runStartupProject(MemcheckWithGdbRunMode); } void MemcheckWithGdbTool::startRemoteTool()