diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index 42ef35402a1..0e2bf0f9c11 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -1466,13 +1466,18 @@ void DebuggerEngine::quitDebugger() { showMessage("QUIT DEBUGGER REQUESTED"); d->m_targetState = DebuggerFinished; - if (state() == InferiorStopOk) { + switch (state()) { + case InferiorStopOk: + case InferiorStopFailed: d->queueShutdownInferior(); - } else if (state() == InferiorRunOk) { + break; + case InferiorRunOk: d->doInterruptInferior(); - } else { + break; + default: // FIXME: We should disable the actions connected to that notifyInferiorIll(); + break; } } diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 3e5f9ddcb05..31e2ec2a705 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -953,6 +953,8 @@ public slots: void executeDebuggerCommand(); + QList runControls() const { return m_snapshotHandler->runControls(); } + public: DebuggerState m_state; uint m_capabilities; @@ -1651,13 +1653,15 @@ void DebuggerPluginPrivate::onCurrentProjectChanged(ProjectExplorer::Project *pr QTC_ASSERT(activeRc, /**/); } for (int i = 0, n = m_snapshotHandler->size(); i != n; ++i) { - DebuggerRunControl *runControl = m_snapshotHandler->at(i); - RunConfiguration *rc = runControl->runConfiguration(); - if (rc == activeRc) { - m_snapshotHandler->setCurrentIndex(i); - DebuggerEngine *engine = runControl->engine(); - updateState(engine); - return; + // Run controls might be deleted during exit. + if (DebuggerRunControl *runControl = m_snapshotHandler->at(i)) { + RunConfiguration *rc = runControl->runConfiguration(); + if (rc == activeRc) { + m_snapshotHandler->setCurrentIndex(i); + DebuggerEngine *engine = runControl->engine(); + updateState(engine); + return; + } } } // No corresponding debugger found. So we are ready to start one. diff --git a/src/plugins/debugger/snapshothandler.cpp b/src/plugins/debugger/snapshothandler.cpp index 0bcfcc9054e..2e9571c7535 100644 --- a/src/plugins/debugger/snapshothandler.cpp +++ b/src/plugins/debugger/snapshothandler.cpp @@ -286,10 +286,22 @@ void SnapshotHandler::setCurrentIndex(int index) reset(); } -DebuggerRunControl *SnapshotHandler::at(int i) +DebuggerRunControl *SnapshotHandler::at(int i) const { return m_snapshots.at(i).data(); } +QList SnapshotHandler::runControls() const +{ + // Return unique list of run controls + QList rc; + rc.reserve(m_snapshots.size()); + foreach(const QPointer &runControlPtr, m_snapshots) + if (DebuggerRunControl *runControl = runControlPtr) + if (!rc.contains(runControl)) + rc.push_back(runControl); + return rc; +} + } // namespace Internal } // namespace Debugger diff --git a/src/plugins/debugger/snapshothandler.h b/src/plugins/debugger/snapshothandler.h index baf92c0c088..84659af2911 100644 --- a/src/plugins/debugger/snapshothandler.h +++ b/src/plugins/debugger/snapshothandler.h @@ -67,7 +67,8 @@ public: void removeSnapshot(DebuggerRunControl *rc); void setCurrentIndex(int index); int size() const { return m_snapshots.size(); } - DebuggerRunControl *at(int i); + DebuggerRunControl *at(int i) const; + QList runControls() const; private: // QAbstractTableModel