forked from qt-creator/qt-creator
debugger: handle shutting down engines from SnapshotWindow <Del> or context menu
This commit is contained in:
@@ -1411,7 +1411,7 @@ void DebuggerEngine::quitDebugger()
|
||||
showMessage("QUIT DEBUGGER REQUESTED");
|
||||
d->m_targetState = DebuggerFinished;
|
||||
if (state() == InferiorStopOk) {
|
||||
d->doShutdownInferior();
|
||||
d->queueShutdownInferior();
|
||||
} else if (state() == InferiorRunOk) {
|
||||
d->doInterruptInferior();
|
||||
} else {
|
||||
|
||||
@@ -1112,7 +1112,7 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, QString *er
|
||||
m_sessionEngine = new SessionEngine;
|
||||
|
||||
// Snapshot
|
||||
m_snapshotHandler = new SnapshotHandler(m_sessionEngine);
|
||||
m_snapshotHandler = new SnapshotHandler;
|
||||
m_snapshotWindow->setModel(m_snapshotHandler->model());
|
||||
|
||||
// Debug mode setup
|
||||
|
||||
@@ -116,9 +116,8 @@ QDebug operator<<(QDebug d, const SnapshotData &f)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SnapshotHandler::SnapshotHandler(SessionEngine *engine)
|
||||
: m_engine(engine),
|
||||
m_positionIcon(QIcon(":/debugger/images/location_16.png")),
|
||||
SnapshotHandler::SnapshotHandler()
|
||||
: m_positionIcon(QIcon(":/debugger/images/location_16.png")),
|
||||
m_emptyIcon(QIcon(":/debugger/images/debugger_empty_14.png"))
|
||||
{
|
||||
m_currentIndex = -1;
|
||||
@@ -223,28 +222,25 @@ bool SnapshotHandler::setData
|
||||
}
|
||||
if (index.isValid() && role == RequestActivateSnapshotRole) {
|
||||
m_currentIndex = index.row();
|
||||
qDebug() << "ACTIVATING INDEX: " << m_currentIndex
|
||||
<< " OF " << size();
|
||||
//qDebug() << "ACTIVATING INDEX: " << m_currentIndex << " OF " << size();
|
||||
DebuggerPlugin::displayDebugger(m_snapshots.at(m_currentIndex));
|
||||
reset();
|
||||
return true;
|
||||
}
|
||||
if (index.isValid() && role == RequestRemoveSnapshotRole) {
|
||||
DebuggerEngine *engine = engineAt(index.row());
|
||||
//qDebug() << "REMOVING " << engine;
|
||||
QTC_ASSERT(engine, return false);
|
||||
engine->quitDebugger();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
// See http://sourceware.org/bugzilla/show_bug.cgi?id=11241.
|
||||
setState(EngineSetupRequested);
|
||||
postCommand("set stack-cache off");
|
||||
|
||||
QMessageBox *mb = showMessageBox(QMessageBox::Critical,
|
||||
tr("Snapshot Reloading"),
|
||||
tr("In order to load snapshots the debugged process needs "
|
||||
"to be stopped. Continuation will not be possible afterwards.\n"
|
||||
"Do you want to stop the debugged process and load the selected "
|
||||
"snapshot?"), QMessageBox::Ok | QMessageBox::Cancel);
|
||||
if (mb->exec() == QMessageBox::Cancel)
|
||||
#endif
|
||||
|
||||
void SnapshotHandler::removeAll()
|
||||
|
||||
@@ -38,11 +38,9 @@
|
||||
namespace Debugger {
|
||||
|
||||
class DebuggerRunControl;
|
||||
class DebuggerStartParameters;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class SessionEngine;
|
||||
class DebuggerEngine;
|
||||
|
||||
|
||||
@@ -58,7 +56,7 @@ class SnapshotHandler : public QAbstractTableModel
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SnapshotHandler(SessionEngine *engine);
|
||||
explicit SnapshotHandler();
|
||||
~SnapshotHandler();
|
||||
|
||||
// Called from SnapshotHandler after a new snapshot has been added
|
||||
@@ -82,7 +80,6 @@ private:
|
||||
DebuggerEngine *engineAt(int i) const;
|
||||
void removeSnapshot(int index);
|
||||
|
||||
SessionEngine *m_engine;
|
||||
int m_currentIndex;
|
||||
QList< QPointer<DebuggerRunControl> > m_snapshots;
|
||||
const QVariant m_positionIcon;
|
||||
|
||||
@@ -93,24 +93,8 @@ void SnapshotWindow::rowActivated(const QModelIndex &index)
|
||||
void SnapshotWindow::removeSnapshots(const QModelIndexList &indexes)
|
||||
{
|
||||
QTC_ASSERT(!indexes.isEmpty(), return);
|
||||
QList<int> list;
|
||||
foreach (const QModelIndex &idx, indexes)
|
||||
list.append(idx.row());
|
||||
removeSnapshots(list);
|
||||
}
|
||||
|
||||
void SnapshotWindow::removeSnapshots(QList<int> list)
|
||||
{
|
||||
if (list.empty())
|
||||
return;
|
||||
const int firstRow = list.front();
|
||||
qSort(list.begin(), list.end());
|
||||
for (int i = list.size(); --i >= 0; )
|
||||
model()->setData(QModelIndex(), list.at(i), RequestRemoveSnapshotRole);
|
||||
|
||||
const int row = qMin(firstRow, model()->rowCount() - 1);
|
||||
if (row >= 0)
|
||||
setCurrentIndex(model()->index(row, 0));
|
||||
model()->setData(idx, QVariant(), RequestRemoveSnapshotRole);
|
||||
}
|
||||
|
||||
void SnapshotWindow::keyPressEvent(QKeyEvent *ev)
|
||||
@@ -137,6 +121,11 @@ void SnapshotWindow::contextMenuEvent(QContextMenuEvent *ev)
|
||||
|
||||
menu.addSeparator();
|
||||
|
||||
QAction *actRemove = menu.addAction(tr("Remove Snapshot"));
|
||||
actRemove->setEnabled(idx.isValid());
|
||||
|
||||
menu.addSeparator();
|
||||
|
||||
QAction *actAdjust = menu.addAction(tr("Adjust Column Widths to Contents"));
|
||||
|
||||
QAction *actAlwaysAdjust =
|
||||
@@ -152,6 +141,8 @@ void SnapshotWindow::contextMenuEvent(QContextMenuEvent *ev)
|
||||
|
||||
if (act == actCreate)
|
||||
model()->setData(idx, idx.row(), RequestMakeSnapshotRole);
|
||||
else if (act == actRemove)
|
||||
model()->setData(idx, idx.row(), RequestRemoveSnapshotRole);
|
||||
else if (act == actAdjust)
|
||||
resizeColumnsToContents();
|
||||
else if (act == actAlwaysAdjust)
|
||||
|
||||
@@ -60,7 +60,6 @@ private:
|
||||
void keyPressEvent(QKeyEvent *ev);
|
||||
void contextMenuEvent(QContextMenuEvent *ev);
|
||||
void removeSnapshots(const QModelIndexList &list);
|
||||
void removeSnapshots(QList<int> rows);
|
||||
|
||||
bool m_alwaysResizeColumnsToContents;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user