diff options
author | Friedemann Kleint <[email protected]> | 2010-08-20 14:19:25 +0200 |
---|---|---|
committer | Friedemann Kleint <[email protected]> | 2010-08-20 14:19:25 +0200 |
commit | 6840c1d19812372076c7fadf35ca0d3eae4dcb72 (patch) | |
tree | b0597c761bc88b34e805940f7e422aa0d3bc6a63 /src/plugins/debugger/debuggerrunner.cpp | |
parent | fa68a545a870778e08db48610e47cfa53c19ddbe (diff) |
Debugger: Refactor run control termination.
Fix breakage introduced by the new asynchronous stop() methods
of the debugger run controls. Allow for RunControl::stop() to
be asynchronous by introducing a return enumeration indicating
that. Introduce additional method aboutToStop() asking user
to quit (tie that to the RunControl instead of having to hack
the behaviour elsewhere).
If asynchronous stop is detected, terminate the ProjectExplorer
asynchronously.
This makes the behaviour consistent across switching sessions/
closing outputwindow tabs and quitting Qt Creator.
Reviewed-by: dt
Rubber-stamped-by: hjk
Diffstat (limited to 'src/plugins/debugger/debuggerrunner.cpp')
-rw-r--r-- | src/plugins/debugger/debuggerrunner.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/plugins/debugger/debuggerrunner.cpp b/src/plugins/debugger/debuggerrunner.cpp index 66935a4d121..7895c28f0c2 100644 --- a/src/plugins/debugger/debuggerrunner.cpp +++ b/src/plugins/debugger/debuggerrunner.cpp @@ -34,6 +34,7 @@ #include "debuggerengine.h" #include "debuggerplugin.h" #include "debuggerstringutils.h" +#include "debuggeruiswitcher.h" #ifdef Q_OS_WIN # include "peutils.h" @@ -48,6 +49,7 @@ #include <projectexplorer/applicationrunconfiguration.h> // For LocalApplication* #include <utils/qtcassert.h> +#include <utils/fancymainwindow.h> #include <coreplugin/icore.h> #include <QtCore/QDebug> @@ -59,6 +61,7 @@ #include <QtGui/QAbstractItemView> #include <QtGui/QTextDocument> #include <QtGui/QTreeWidget> +#include <QtGui/QMessageBox> using namespace ProjectExplorer; using namespace Debugger::Internal; @@ -509,11 +512,27 @@ void DebuggerRunControl::showMessage(const QString &msg, int channel) } } -void DebuggerRunControl::stop() +bool DebuggerRunControl::aboutToStop() const { - m_running = false; - QTC_ASSERT(m_engine, return); + QTC_ASSERT(isRunning(), return true;) + + const QString question = tr("A debugging session are still in progress. " + "Terminating the session in the current" + " state can leave the target in an inconsistent state." + " Would you still like to terminate it?"); + + const QMessageBox::StandardButton answer = + QMessageBox::question(DebuggerUISwitcher::instance()->mainWindow(), + tr("Close Debugging Session"), question, + QMessageBox::Yes|QMessageBox::No); + return answer == QMessageBox::Yes; +} + +RunControl::StopResult DebuggerRunControl::stop() +{ + QTC_ASSERT(m_engine, return StoppedSynchronously); m_engine->quitDebugger(); + return AsynchronousStop; } void DebuggerRunControl::debuggingFinished() |