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) {
QDebug operator<<(QDebug d, DebuggerState state)
{
- return d << stateName(state) << '(' << int(state) << ')';
+ return d << DebuggerManager::stateName(state) << '(' << int(state) << ')';
}
//////////////////////////////////////////////////////////////////////
#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>
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
addAutoReleasedObject(new DebuggingHelperOptionPage);
foreach (Core::IOptionsPage* op, engineOptionPages)
addAutoReleasedObject(op);
-
+ addAutoReleasedObject(new DebuggerListener);
m_locationMark = 0;