debugger: remove finished engines from snapshot list

This commit is contained in:
hjk
2010-07-13 17:57:39 +02:00
parent 4f4167a310
commit fa8cf20dc0
4 changed files with 39 additions and 14 deletions

View File

@@ -461,7 +461,7 @@ void DebuggerEngine::handleCommand(int role, const QVariant &value)
break; break;
case RequestExecExitRole: case RequestExecExitRole:
d->doShutdownInferior(); d->queueShutdownInferior();
break; break;
case RequestMakeSnapshotRole: 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 void DebuggerEngine::showMessage(const QString &msg, int channel, int timeout) const
{ {
//if (msg.size() && msg.at(0).isUpper() && msg.at(1).isUpper()) if (msg.size() && msg.at(0).isUpper() && msg.at(1).isUpper())
// qDebug() << qPrintable(msg) << "IN STATE" << state(); qDebug() << qPrintable(msg) << "IN STATE" << state();
d->m_runControl->showMessage(msg, channel); d->m_runControl->showMessage(msg, channel);
plugin()->showMessage(msg, channel, timeout); plugin()->showMessage(msg, channel, timeout);
} }

View File

@@ -2694,6 +2694,7 @@ void DebuggerPlugin::runControlStarted(DebuggerRunControl *runControl)
void DebuggerPlugin::runControlFinished(DebuggerRunControl *runControl) void DebuggerPlugin::runControlFinished(DebuggerRunControl *runControl)
{ {
Q_UNUSED(runControl); Q_UNUSED(runControl);
d->m_sessionEngine->m_snapshotHandler->removeSnapshot(runControl);
d->disconnectEngine(); d->disconnectEngine();
} }

View File

@@ -127,14 +127,19 @@ SnapshotHandler::SnapshotHandler(SessionEngine *engine)
SnapshotHandler::~SnapshotHandler() SnapshotHandler::~SnapshotHandler()
{ {
for (int i = m_snapshots.size(); --i >= 0; ) { for (int i = m_snapshots.size(); --i >= 0; ) {
QString file = engineAt(i)->startParameters().coreFile; if (DebuggerEngine *engine = engineAt(i)) {
QFile::remove(file); QString fileName = engine->startParameters().coreFile;
if (!fileName.isEmpty())
QFile::remove(fileName);
}
} }
} }
DebuggerEngine *SnapshotHandler::engineAt(int i) const 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 int SnapshotHandler::rowCount(const QModelIndex &parent) const
@@ -154,6 +159,13 @@ QVariant SnapshotHandler::data(const QModelIndex &index, int role) const
return QVariant(); return QVariant();
const DebuggerEngine *engine = engineAt(index.row()); const DebuggerEngine *engine = engineAt(index.row());
if (role == SnapshotCapabilityRole)
return engine && (engine->debuggerCapabilities() & SnapshotCapability);
if (!engine)
return QLatin1String("<finished>");
const DebuggerStartParameters &sp = engine->startParameters(); const DebuggerStartParameters &sp = engine->startParameters();
if (role == Qt::DisplayRole) { if (role == Qt::DisplayRole) {
@@ -166,9 +178,6 @@ QVariant SnapshotHandler::data(const QModelIndex &index, int role) const
return QVariant(); return QVariant();
} }
if (role == SnapshotCapabilityRole)
return engine->debuggerCapabilities() & SnapshotCapability;
if (role == Qt::ToolTipRole) { if (role == Qt::ToolTipRole) {
//: Tooltip for variable //: Tooltip for variable
//return snapshot.toToolTip(); //return snapshot.toToolTip();
@@ -207,7 +216,9 @@ bool SnapshotHandler::setData
{ {
Q_UNUSED(value); Q_UNUSED(value);
if (index.isValid() && role == RequestMakeSnapshotRole) { if (index.isValid() && role == RequestMakeSnapshotRole) {
engineAt(index.row())->makeSnapshot(); DebuggerEngine *engine = engineAt(index.row());
QTC_ASSERT(engine, return false);
engine->makeSnapshot();
return true; return true;
} }
if (index.isValid() && role == RequestActivateSnapshotRole) { if (index.isValid() && role == RequestActivateSnapshotRole) {
@@ -245,14 +256,26 @@ void SnapshotHandler::removeAll()
void SnapshotHandler::appendSnapshot(DebuggerRunControl *rc) void SnapshotHandler::appendSnapshot(DebuggerRunControl *rc)
{ {
//return; // FIXME
m_snapshots.append(rc); m_snapshots.append(rc);
m_currentIndex = size() - 1; m_currentIndex = size() - 1;
reset(); reset();
} }
void SnapshotHandler::removeSnapshot(DebuggerRunControl *rc)
{
int index = m_snapshots.indexOf(rc);
QTC_ASSERT(index != -1, return);
removeSnapshot(index);
}
void SnapshotHandler::removeSnapshot(int 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); m_snapshots.removeAt(index);
if (index == m_currentIndex) if (index == m_currentIndex)
m_currentIndex = -1; m_currentIndex = -1;

View File

@@ -33,7 +33,7 @@
#include "stackframe.h" #include "stackframe.h"
#include <QtCore/QAbstractItemModel> #include <QtCore/QAbstractItemModel>
#include <QtCore/QDateTime> #include <QtCore/QPointer>
namespace Debugger { namespace Debugger {
@@ -63,10 +63,10 @@ public:
// Called from SnapshotHandler after a new snapshot has been added // Called from SnapshotHandler after a new snapshot has been added
void removeAll(); void removeAll();
void removeSnapshot(int index);
QAbstractItemModel *model() { return this; } QAbstractItemModel *model() { return this; }
int currentIndex() const { return m_currentIndex; } int currentIndex() const { return m_currentIndex; }
void appendSnapshot(DebuggerRunControl *rc); void appendSnapshot(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(); }
@@ -80,10 +80,11 @@ private:
Qt::ItemFlags flags(const QModelIndex &index) const; Qt::ItemFlags flags(const QModelIndex &index) const;
Q_SLOT void resetModel() { reset(); } Q_SLOT void resetModel() { reset(); }
DebuggerEngine *engineAt(int i) const; DebuggerEngine *engineAt(int i) const;
void removeSnapshot(int index);
SessionEngine *m_engine; SessionEngine *m_engine;
int m_currentIndex; int m_currentIndex;
QList<DebuggerRunControl *> m_snapshots; QList< QPointer<DebuggerRunControl> > m_snapshots;
const QVariant m_positionIcon; const QVariant m_positionIcon;
const QVariant m_emptyIcon; const QVariant m_emptyIcon;
}; };