Debugger: Improve exit handling.

This commit is contained in:
Friedemann Kleint
2010-08-18 11:08:50 +02:00
parent 172288b593
commit 83f3119c97
4 changed files with 34 additions and 12 deletions

View File

@@ -1466,13 +1466,18 @@ void DebuggerEngine::quitDebugger()
{ {
showMessage("QUIT DEBUGGER REQUESTED"); showMessage("QUIT DEBUGGER REQUESTED");
d->m_targetState = DebuggerFinished; d->m_targetState = DebuggerFinished;
if (state() == InferiorStopOk) { switch (state()) {
case InferiorStopOk:
case InferiorStopFailed:
d->queueShutdownInferior(); d->queueShutdownInferior();
} else if (state() == InferiorRunOk) { break;
case InferiorRunOk:
d->doInterruptInferior(); d->doInterruptInferior();
} else { break;
default:
// FIXME: We should disable the actions connected to that // FIXME: We should disable the actions connected to that
notifyInferiorIll(); notifyInferiorIll();
break;
} }
} }

View File

@@ -953,6 +953,8 @@ public slots:
void executeDebuggerCommand(); void executeDebuggerCommand();
QList<DebuggerRunControl *> runControls() const { return m_snapshotHandler->runControls(); }
public: public:
DebuggerState m_state; DebuggerState m_state;
uint m_capabilities; uint m_capabilities;
@@ -1651,13 +1653,15 @@ void DebuggerPluginPrivate::onCurrentProjectChanged(ProjectExplorer::Project *pr
QTC_ASSERT(activeRc, /**/); QTC_ASSERT(activeRc, /**/);
} }
for (int i = 0, n = m_snapshotHandler->size(); i != n; ++i) { for (int i = 0, n = m_snapshotHandler->size(); i != n; ++i) {
DebuggerRunControl *runControl = m_snapshotHandler->at(i); // Run controls might be deleted during exit.
RunConfiguration *rc = runControl->runConfiguration(); if (DebuggerRunControl *runControl = m_snapshotHandler->at(i)) {
if (rc == activeRc) { RunConfiguration *rc = runControl->runConfiguration();
m_snapshotHandler->setCurrentIndex(i); if (rc == activeRc) {
DebuggerEngine *engine = runControl->engine(); m_snapshotHandler->setCurrentIndex(i);
updateState(engine); DebuggerEngine *engine = runControl->engine();
return; updateState(engine);
return;
}
} }
} }
// No corresponding debugger found. So we are ready to start one. // No corresponding debugger found. So we are ready to start one.

View File

@@ -286,10 +286,22 @@ void SnapshotHandler::setCurrentIndex(int index)
reset(); reset();
} }
DebuggerRunControl *SnapshotHandler::at(int i) DebuggerRunControl *SnapshotHandler::at(int i) const
{ {
return m_snapshots.at(i).data(); return m_snapshots.at(i).data();
} }
QList<DebuggerRunControl*> SnapshotHandler::runControls() const
{
// Return unique list of run controls
QList<DebuggerRunControl*> rc;
rc.reserve(m_snapshots.size());
foreach(const QPointer<DebuggerRunControl> &runControlPtr, m_snapshots)
if (DebuggerRunControl *runControl = runControlPtr)
if (!rc.contains(runControl))
rc.push_back(runControl);
return rc;
}
} // namespace Internal } // namespace Internal
} // namespace Debugger } // namespace Debugger

View File

@@ -67,7 +67,8 @@ public:
void removeSnapshot(DebuggerRunControl *rc); void removeSnapshot(DebuggerRunControl *rc);
void setCurrentIndex(int index); void setCurrentIndex(int index);
int size() const { return m_snapshots.size(); } int size() const { return m_snapshots.size(); }
DebuggerRunControl *at(int i); DebuggerRunControl *at(int i) const;
QList<DebuggerRunControl*> runControls() const;
private: private:
// QAbstractTableModel // QAbstractTableModel