From fa8cf20dc0e99d7c0c9fbdbd99060faa5457a2d6 Mon Sep 17 00:00:00 2001 From: hjk <qtc-committer@nokia.com> Date: Tue, 13 Jul 2010 17:57:39 +0200 Subject: [PATCH] debugger: remove finished engines from snapshot list --- src/plugins/debugger/debuggerengine.cpp | 6 ++-- src/plugins/debugger/debuggerplugin.cpp | 1 + src/plugins/debugger/snapshothandler.cpp | 39 +++++++++++++++++++----- src/plugins/debugger/snapshothandler.h | 7 +++-- 4 files changed, 39 insertions(+), 14 deletions(-) diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index 10042e7f654..515cbb52ab5 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -461,7 +461,7 @@ void DebuggerEngine::handleCommand(int role, const QVariant &value) break; case RequestExecExitRole: - d->doShutdownInferior(); + d->queueShutdownInferior(); break; case RequestMakeSnapshotRole: @@ -654,8 +654,8 @@ void DebuggerEngine::setRegisterValue(int regnr, const QString &value) void DebuggerEngine::showMessage(const QString &msg, int channel, int timeout) const { - //if (msg.size() && msg.at(0).isUpper() && msg.at(1).isUpper()) - // qDebug() << qPrintable(msg) << "IN STATE" << state(); + if (msg.size() && msg.at(0).isUpper() && msg.at(1).isUpper()) + qDebug() << qPrintable(msg) << "IN STATE" << state(); d->m_runControl->showMessage(msg, channel); plugin()->showMessage(msg, channel, timeout); } diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 44dbe9fa212..fa8260e4e5b 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -2694,6 +2694,7 @@ void DebuggerPlugin::runControlStarted(DebuggerRunControl *runControl) void DebuggerPlugin::runControlFinished(DebuggerRunControl *runControl) { Q_UNUSED(runControl); + d->m_sessionEngine->m_snapshotHandler->removeSnapshot(runControl); d->disconnectEngine(); } diff --git a/src/plugins/debugger/snapshothandler.cpp b/src/plugins/debugger/snapshothandler.cpp index 6d05181296a..62bf616c6b5 100644 --- a/src/plugins/debugger/snapshothandler.cpp +++ b/src/plugins/debugger/snapshothandler.cpp @@ -127,14 +127,19 @@ SnapshotHandler::SnapshotHandler(SessionEngine *engine) SnapshotHandler::~SnapshotHandler() { for (int i = m_snapshots.size(); --i >= 0; ) { - QString file = engineAt(i)->startParameters().coreFile; - QFile::remove(file); + if (DebuggerEngine *engine = engineAt(i)) { + QString fileName = engine->startParameters().coreFile; + if (!fileName.isEmpty()) + QFile::remove(fileName); + } } } DebuggerEngine *SnapshotHandler::engineAt(int i) const { - return m_snapshots.at(i)->engine(); + DebuggerEngine *engine = m_snapshots.at(i)->engine(); + QTC_ASSERT(engine, qDebug() << "ENGINE AT " << i << "DELETED"); + return engine; } int SnapshotHandler::rowCount(const QModelIndex &parent) const @@ -154,6 +159,13 @@ QVariant SnapshotHandler::data(const QModelIndex &index, int role) const return QVariant(); const DebuggerEngine *engine = engineAt(index.row()); + + if (role == SnapshotCapabilityRole) + return engine && (engine->debuggerCapabilities() & SnapshotCapability); + + if (!engine) + return QLatin1String("<finished>"); + const DebuggerStartParameters &sp = engine->startParameters(); if (role == Qt::DisplayRole) { @@ -166,9 +178,6 @@ QVariant SnapshotHandler::data(const QModelIndex &index, int role) const return QVariant(); } - if (role == SnapshotCapabilityRole) - return engine->debuggerCapabilities() & SnapshotCapability; - if (role == Qt::ToolTipRole) { //: Tooltip for variable //return snapshot.toToolTip(); @@ -207,7 +216,9 @@ bool SnapshotHandler::setData { Q_UNUSED(value); if (index.isValid() && role == RequestMakeSnapshotRole) { - engineAt(index.row())->makeSnapshot(); + DebuggerEngine *engine = engineAt(index.row()); + QTC_ASSERT(engine, return false); + engine->makeSnapshot(); return true; } if (index.isValid() && role == RequestActivateSnapshotRole) { @@ -245,14 +256,26 @@ void SnapshotHandler::removeAll() void SnapshotHandler::appendSnapshot(DebuggerRunControl *rc) { + //return; // FIXME m_snapshots.append(rc); m_currentIndex = size() - 1; reset(); } +void SnapshotHandler::removeSnapshot(DebuggerRunControl *rc) +{ + int index = m_snapshots.indexOf(rc); + QTC_ASSERT(index != -1, return); + removeSnapshot(index); +} + void SnapshotHandler::removeSnapshot(int index) { - QFile::remove(engineAt(index)->startParameters().coreFile); + const DebuggerEngine *engine = engineAt(index); + QTC_ASSERT(engine, return); + QString fileName = engine->startParameters().coreFile; + if (!fileName.isEmpty()) + QFile::remove(fileName); m_snapshots.removeAt(index); if (index == m_currentIndex) m_currentIndex = -1; diff --git a/src/plugins/debugger/snapshothandler.h b/src/plugins/debugger/snapshothandler.h index 1f89c102a08..413367ca712 100644 --- a/src/plugins/debugger/snapshothandler.h +++ b/src/plugins/debugger/snapshothandler.h @@ -33,7 +33,7 @@ #include "stackframe.h" #include <QtCore/QAbstractItemModel> -#include <QtCore/QDateTime> +#include <QtCore/QPointer> namespace Debugger { @@ -63,10 +63,10 @@ public: // Called from SnapshotHandler after a new snapshot has been added void removeAll(); - void removeSnapshot(int index); QAbstractItemModel *model() { return this; } int currentIndex() const { return m_currentIndex; } void appendSnapshot(DebuggerRunControl *rc); + void removeSnapshot(DebuggerRunControl *rc); void setCurrentIndex(int index); int size() const { return m_snapshots.size(); } @@ -80,10 +80,11 @@ private: Qt::ItemFlags flags(const QModelIndex &index) const; Q_SLOT void resetModel() { reset(); } DebuggerEngine *engineAt(int i) const; + void removeSnapshot(int index); SessionEngine *m_engine; int m_currentIndex; - QList<DebuggerRunControl *> m_snapshots; + QList< QPointer<DebuggerRunControl> > m_snapshots; const QVariant m_positionIcon; const QVariant m_emptyIcon; }; -- GitLab