Commit 9dc11c5d authored by Friedemann Kleint's avatar Friedemann Kleint

Debugger: Handle core shutdown, prompt user to terminate debugging.

Add a corelistener and trigger on shutdown. Notify about critical
states.
Reviewed-by: default avatarOswald Buddenhagen <oswald.buddenhagen@nokia.com>
parent a3580ab5
......@@ -180,7 +180,7 @@ using namespace Debugger::Internal;
static const QString tooltipIName = "tooltip";
static const char *stateName(int s)
const char *DebuggerManager::stateName(int s)
{
#define SN(x) case x: return #x;
switch (s) {
......@@ -1766,7 +1766,7 @@ void DebuggerManager::ensureLogVisible()
QDebug operator<<(QDebug d, DebuggerState state)
{
return d << stateName(state) << '(' << int(state) << ')';
return d << DebuggerManager::stateName(state) << '(' << int(state) << ')';
}
//////////////////////////////////////////////////////////////////////
......
......@@ -241,6 +241,8 @@ public slots:
void showStatusMessage(const QString &msg, int timeout = -1); // -1 forever
void clearCppCodeModelSnapshot();
static const char *stateName(int s);
public slots: // FIXME
void showDebuggerOutput(const QString &msg)
{ showDebuggerOutput(LogDebug, msg); }
......
......@@ -47,6 +47,7 @@
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/findplaceholder.h>
#include <coreplugin/icore.h>
#include <coreplugin/icorelistener.h>
#include <coreplugin/messagemanager.h>
#include <coreplugin/minisplitter.h>
#include <coreplugin/modemanager.h>
......@@ -204,6 +205,60 @@ DebugMode::~DebugMode()
EditorManager::instance()->setParent(0);
}
///////////////////////////////////////////////////////////////////////
//
// DebuggerListener: Close the debugging session if running.
//
///////////////////////////////////////////////////////////////////////
class DebuggerListener : public Core::ICoreListener {
Q_OBJECT
public:
explicit DebuggerListener(QObject *parent = 0);
virtual bool coreAboutToClose();
};
DebuggerListener::DebuggerListener(QObject *parent) :
Core::ICoreListener(parent)
{
}
bool DebuggerListener::coreAboutToClose()
{
DebuggerManager *mgr = DebuggerManager::instance();
if (!mgr)
return true;
// Ask to terminate the session.
const QString title = tr("Close Debugging Session");
bool cleanTermination = false;
switch (mgr->state()) {
case DebuggerNotReady:
return true;
case AdapterStarted: // Most importantly, terminating a running
case AdapterStartFailed: // debuggee can cause problems.
case InferiorUnrunnable:
case InferiorStartFailed:
case InferiorStopped:
case InferiorShutDown:
cleanTermination = true;
break;
default:
break;
}
const QString question = cleanTermination ?
tr("A debugging session is still in progress. Would you like to terminate it?") :
tr("A debugging session is still in progress. Terminating the session in the current"
" state (%1) can leave the target in an inconsistent state."
" Would you like to terminate it?")
.arg(QLatin1String(DebuggerManager::stateName(mgr->state())));
QMessageBox::StandardButton answer = QMessageBox::question(0, title, question,
QMessageBox::Yes|QMessageBox::No, QMessageBox::No);
if (answer == QMessageBox::No)
return false;
mgr->exitDebugger();
return true;
}
} // namespace Internal
} // namespace Debugger
......@@ -753,7 +808,7 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *errorMess
addAutoReleasedObject(new DebuggingHelperOptionPage);
foreach (Core::IOptionsPage* op, engineOptionPages)
addAutoReleasedObject(op);
addAutoReleasedObject(new DebuggerListener);
m_locationMark = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment