forked from qt-creator/qt-creator
debugger: remove finished engines from snapshot list
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user