aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/debugger/debuggerplugin.cpp
diff options
context:
space:
mode:
authorhjk <[email protected]>2014-09-04 13:48:44 +0200
committerhjk <[email protected]>2014-09-04 15:57:44 +0200
commit50e951dcb4a421d94e387fb91d527a9ba4bbce00 (patch)
treef3948529fa4bb3ac5c8125bea4ad7eb25f1f7a5d /src/plugins/debugger/debuggerplugin.cpp
parent3df7f9498ae9044cd08e5b2b4bb0afba04fb4d65 (diff)
ProjectExplorer: Streamline the canRun(Project) functions
There's no real need to go through the chain of decisions a second time to retrieve a message. Change-Id: Id32ee486a7555f8eaf38668f23ec8fb2e179db89 Reviewed-by: Daniel Teske <[email protected]>
Diffstat (limited to 'src/plugins/debugger/debuggerplugin.cpp')
-rw-r--r--src/plugins/debugger/debuggerplugin.cpp25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp
index 6a9884218c3..175bebe12e3 100644
--- a/src/plugins/debugger/debuggerplugin.cpp
+++ b/src/plugins/debugger/debuggerplugin.cpp
@@ -1526,10 +1526,10 @@ void DebuggerPluginPrivate::onCurrentProjectChanged(Project *project)
m_interruptAction->setEnabled(false);
m_continueAction->setEnabled(false);
m_exitAction->setEnabled(false);
- ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
- const bool canRun = pe->canRun(project, DebugRunMode);
+ QString whyNot;
+ const bool canRun = ProjectExplorerPlugin::canRun(project, DebugRunMode, &whyNot);
m_startAction->setEnabled(canRun);
- m_startAction->setToolTip(canRun ? QString() : pe->cannotRunReason(project, DebugRunMode));
+ m_startAction->setToolTip(whyNot);
m_debugWithoutDeployAction->setEnabled(canRun);
setProxyAction(m_visibleStartAction, Core::Id(Constants::DEBUG));
}
@@ -2278,9 +2278,8 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
m_hiddenStopAction->setAction(m_interruptAction);
m_localsAndExpressionsWindow->setShowLocals(false);
} else if (state == DebuggerFinished) {
- ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
Project *project = SessionManager::startupProject();
- const bool canRun = pe->canRun(project, DebugRunMode);
+ const bool canRun = ProjectExplorerPlugin::canRun(project, DebugRunMode);
// We don't want to do anything anymore.
m_interruptAction->setEnabled(false);
m_continueAction->setEnabled(false);
@@ -2380,28 +2379,24 @@ void DebuggerPluginPrivate::updateDebugActions()
if (m_currentEngine->state() != DebuggerNotReady)
return;
- ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
Project *project = SessionManager::startupProject();
- const bool canRun = pe->canRun(project, DebugRunMode);
+ QString whyNot;
+ const bool canRun = ProjectExplorerPlugin::canRun(project, DebugRunMode, &whyNot);
m_startAction->setEnabled(canRun);
- m_startAction->setToolTip(canRun ? QString() : pe->cannotRunReason(project, DebugRunMode));
+ m_startAction->setToolTip(whyNot);
m_debugWithoutDeployAction->setEnabled(canRun);
// Step into/next: Start and break at 'main' unless a debugger is running.
if (m_snapshotHandler->currentIndex() < 0) {
- const bool canRunAndBreakMain = pe->canRun(project, DebugRunModeWithBreakOnMain);
+ QString toolTip;
+ const bool canRunAndBreakMain
+ = ProjectExplorerPlugin::canRun(project, DebugRunModeWithBreakOnMain, &toolTip);
m_stepAction->setEnabled(canRunAndBreakMain);
m_nextAction->setEnabled(canRunAndBreakMain);
- QString toolTip;
if (canRunAndBreakMain) {
QTC_ASSERT(project, return ; );
toolTip = tr("Start \"%1\" and break at function \"main()\"")
.arg(project->displayName());
- } else {
- // Do not display long tooltip saying run mode is not supported
- // for project for projects to which 'break at main' is not applicable.
- if (!canRun)
- toolTip = pe->cannotRunReason(project, DebugRunModeWithBreakOnMain);
}
m_stepAction->setToolTip(toolTip);
m_nextAction->setToolTip(toolTip);