forked from qt-creator/qt-creator
Debugger: Re-enable watchers after ending a debugger run
In that state one should be able to remove them. Change-Id: I9c1383decb087971cdc01607c32801f6ac22f99d Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -1820,6 +1820,8 @@ void DebuggerPluginPrivate::connectEngine(DebuggerEngine *engine)
|
|||||||
m_watchersView->setModel(engine->watchModel());
|
m_watchersView->setModel(engine->watchModel());
|
||||||
m_inspectorView->setModel(engine->watchModel());
|
m_inspectorView->setModel(engine->watchModel());
|
||||||
|
|
||||||
|
engine->watchHandler()->resetWatchers();
|
||||||
|
|
||||||
mainWindow()->setEngineDebugLanguages(engine->startParameters().languages);
|
mainWindow()->setEngineDebugLanguages(engine->startParameters().languages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -863,22 +863,7 @@ bool WatchModel::setData(const QModelIndex &idx, const QVariant &value, int role
|
|||||||
case Qt::EditRole:
|
case Qt::EditRole:
|
||||||
switch (idx.column()) {
|
switch (idx.column()) {
|
||||||
case 0: {
|
case 0: {
|
||||||
QByteArray exp = value.toByteArray();
|
m_handler->watchExpression(value.toString());
|
||||||
if (!exp.isEmpty()) {
|
|
||||||
theWatcherNames.remove(item->d.exp);
|
|
||||||
item->d.exp = exp;
|
|
||||||
item->d.name = QString::fromLatin1(exp);
|
|
||||||
theWatcherNames[exp] = theWatcherCount++;
|
|
||||||
m_handler->saveWatchers();
|
|
||||||
if (engine()->state() == DebuggerNotReady) {
|
|
||||||
item->d.setAllUnneeded();
|
|
||||||
item->d.setValue(QString(QLatin1Char(' ')));
|
|
||||||
item->d.setHasChildren(false);
|
|
||||||
} else {
|
|
||||||
engine()->updateWatchData(item->d);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_handler->updateWatchersWindow();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1: // Change value
|
case 1: // Change value
|
||||||
@@ -922,8 +907,9 @@ bool WatchModel::setData(const QModelIndex &idx, const QVariant &value, int role
|
|||||||
Qt::ItemFlags WatchItem::flags(int column) const
|
Qt::ItemFlags WatchItem::flags(int column) const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(model(), return Qt::ItemFlags());
|
QTC_ASSERT(model(), return Qt::ItemFlags());
|
||||||
if (!watchModel()->contentIsValid() && !d.isInspect())
|
DebuggerEngine *engine = watchModel()->engine();
|
||||||
return Qt::ItemFlags();
|
QTC_ASSERT(engine, return Qt::ItemFlags());
|
||||||
|
const DebuggerState state = engine->state();
|
||||||
|
|
||||||
// Enabled, editable, selectable, checkable, and can be used both as the
|
// Enabled, editable, selectable, checkable, and can be used both as the
|
||||||
// source of a drag and drop operation and as a drop target.
|
// source of a drag and drop operation and as a drop target.
|
||||||
@@ -931,14 +917,12 @@ Qt::ItemFlags WatchItem::flags(int column) const
|
|||||||
const Qt::ItemFlags notEditable = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
|
const Qt::ItemFlags notEditable = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
|
||||||
const Qt::ItemFlags editable = notEditable | Qt::ItemIsEditable;
|
const Qt::ItemFlags editable = notEditable | Qt::ItemIsEditable;
|
||||||
|
|
||||||
// Disable editing if debuggee is positively running except for Inspector data
|
|
||||||
DebuggerEngine *engine = watchModel()->engine();
|
|
||||||
const bool isRunning = engine && engine->state() == InferiorRunOk;
|
|
||||||
if (isRunning && engine && !engine->hasCapability(AddWatcherWhileRunningCapability) &&
|
|
||||||
!d.isInspect())
|
|
||||||
return notEditable;
|
|
||||||
|
|
||||||
if (d.isWatcher()) {
|
if (d.isWatcher()) {
|
||||||
|
if (state != InferiorStopOk
|
||||||
|
&& state != DebuggerNotReady
|
||||||
|
&& state != DebuggerFinished
|
||||||
|
&& !engine->hasCapability(AddWatcherWhileRunningCapability))
|
||||||
|
return Qt::ItemFlags();
|
||||||
if (column == 0 && d.iname.count('.') == 1)
|
if (column == 0 && d.iname.count('.') == 1)
|
||||||
return editable; // Watcher names are editable.
|
return editable; // Watcher names are editable.
|
||||||
|
|
||||||
@@ -950,6 +934,8 @@ Qt::ItemFlags WatchItem::flags(int column) const
|
|||||||
return editable; // Watcher values are sometimes editable.
|
return editable; // Watcher values are sometimes editable.
|
||||||
}
|
}
|
||||||
} else if (d.isLocal()) {
|
} else if (d.isLocal()) {
|
||||||
|
if (state != InferiorStopOk && !engine->hasCapability(AddWatcherWhileRunningCapability))
|
||||||
|
return Qt::ItemFlags();
|
||||||
if (column == 1 && d.valueEditable)
|
if (column == 1 && d.valueEditable)
|
||||||
return editable; // Locals values are sometimes editable.
|
return editable; // Locals values are sometimes editable.
|
||||||
} else if (d.isInspect()) {
|
} else if (d.isInspect()) {
|
||||||
@@ -1182,6 +1168,7 @@ void WatchHandler::cleanup()
|
|||||||
{
|
{
|
||||||
m_model->m_expandedINames.clear();
|
m_model->m_expandedINames.clear();
|
||||||
theWatcherNames.remove(QByteArray());
|
theWatcherNames.remove(QByteArray());
|
||||||
|
saveWatchers();
|
||||||
m_model->reinitialize();
|
m_model->reinitialize();
|
||||||
emit m_model->updateFinished();
|
emit m_model->updateFinished();
|
||||||
m_separatedView->hide();
|
m_separatedView->hide();
|
||||||
@@ -1250,16 +1237,12 @@ void WatchModel::reexpandItems()
|
|||||||
void WatchHandler::insertData(const WatchData &data)
|
void WatchHandler::insertData(const WatchData &data)
|
||||||
{
|
{
|
||||||
m_model->insertDataItem(data);
|
m_model->insertDataItem(data);
|
||||||
m_contentsValid = true;
|
|
||||||
updateWatchersWindow();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WatchHandler::insertDataList(const QList<WatchData> &list)
|
void WatchHandler::insertDataList(const QList<WatchData> &list)
|
||||||
{
|
{
|
||||||
for (int i = 0, n = list.size(); i != n; ++i)
|
for (int i = 0, n = list.size(); i != n; ++i)
|
||||||
m_model->insertDataItem(list.at(i));
|
m_model->insertDataItem(list.at(i));
|
||||||
m_contentsValid = true;
|
|
||||||
updateWatchersWindow();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WatchHandler::removeAllData(bool includeInspectData)
|
void WatchHandler::removeAllData(bool includeInspectData)
|
||||||
@@ -1278,13 +1261,22 @@ void WatchHandler::resetValueCache()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WatchHandler::resetWatchers()
|
||||||
|
{
|
||||||
|
loadSessionData();
|
||||||
|
}
|
||||||
|
|
||||||
void WatchHandler::notifyUpdateStarted()
|
void WatchHandler::notifyUpdateStarted()
|
||||||
{
|
{
|
||||||
m_model->m_requestUpdateTimer.start(80);
|
m_model->m_requestUpdateTimer.start(80);
|
||||||
|
m_contentsValid = false;
|
||||||
|
updateWatchersWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WatchHandler::notifyUpdateFinished()
|
void WatchHandler::notifyUpdateFinished()
|
||||||
{
|
{
|
||||||
|
m_contentsValid = true;
|
||||||
|
updateWatchersWindow();
|
||||||
m_model->m_requestUpdateTimer.stop();
|
m_model->m_requestUpdateTimer.stop();
|
||||||
emit m_model->updateFinished();
|
emit m_model->updateFinished();
|
||||||
}
|
}
|
||||||
@@ -1323,25 +1315,19 @@ QByteArray WatchHandler::watcherName(const QByteArray &exp)
|
|||||||
|
|
||||||
void WatchHandler::watchExpression(const QString &exp0, const QString &name)
|
void WatchHandler::watchExpression(const QString &exp0, const QString &name)
|
||||||
{
|
{
|
||||||
QString exp = exp0;
|
|
||||||
|
|
||||||
QTC_ASSERT(m_engine, return);
|
|
||||||
// Do not insert the same entry more then once.
|
// Do not insert the same entry more then once.
|
||||||
if (theWatcherNames.value(exp.toLatin1()))
|
QByteArray exp = exp0.toLatin1();
|
||||||
|
if (exp.isEmpty() || theWatcherNames.contains(exp))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// FIXME: 'exp' can contain illegal characters
|
theWatcherNames[exp] = theWatcherCount++;
|
||||||
exp.replace(QLatin1Char('#'), QString());
|
|
||||||
|
|
||||||
WatchData data;
|
WatchData data;
|
||||||
data.exp = exp.toLatin1();
|
data.exp = exp;
|
||||||
data.name = name.isEmpty() ? exp : name;
|
data.name = name.isEmpty() ? exp0 : name;
|
||||||
theWatcherNames[data.exp] = theWatcherCount++;
|
data.iname = watcherName(exp);
|
||||||
saveWatchers();
|
saveWatchers();
|
||||||
|
|
||||||
if (exp.isEmpty())
|
|
||||||
data.setAllUnneeded();
|
|
||||||
data.iname = watcherName(data.exp);
|
|
||||||
if (m_engine->state() == DebuggerNotReady) {
|
if (m_engine->state() == DebuggerNotReady) {
|
||||||
data.setAllUnneeded();
|
data.setAllUnneeded();
|
||||||
data.setValue(QString(QLatin1Char(' ')));
|
data.setValue(QString(QLatin1Char(' ')));
|
||||||
@@ -1471,14 +1457,8 @@ void WatchHandler::updateWatchersWindow()
|
|||||||
emit m_model->columnAdjustmentRequested();
|
emit m_model->columnAdjustmentRequested();
|
||||||
|
|
||||||
// Force show/hide of watchers and return view.
|
// Force show/hide of watchers and return view.
|
||||||
static int previousShowWatch = -1;
|
int showWatch = !theWatcherNames.isEmpty();
|
||||||
static int previousShowReturn = -1;
|
|
||||||
int showWatch = !m_model->m_watchRoot->children().isEmpty();
|
|
||||||
int showReturn = !m_model->m_returnRoot->children().isEmpty();
|
int showReturn = !m_model->m_returnRoot->children().isEmpty();
|
||||||
if (showWatch == previousShowWatch && showReturn == previousShowReturn)
|
|
||||||
return;
|
|
||||||
previousShowWatch = showWatch;
|
|
||||||
previousShowReturn = showReturn;
|
|
||||||
Internal::updateWatchersWindow(showWatch, showReturn);
|
Internal::updateWatchersWindow(showWatch, showReturn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1764,7 +1744,6 @@ void WatchHandler::editTypeFormats(bool includeLocals, const QByteArray &iname)
|
|||||||
void WatchHandler::scheduleResetLocation()
|
void WatchHandler::scheduleResetLocation()
|
||||||
{
|
{
|
||||||
m_contentsValid = false;
|
m_contentsValid = false;
|
||||||
//m_contentsValid = true; // FIXME
|
|
||||||
m_resetLocationScheduled = true;
|
m_resetLocationScheduled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -244,6 +244,7 @@ public:
|
|||||||
void removeItemByIName(const QByteArray &iname);
|
void removeItemByIName(const QByteArray &iname);
|
||||||
void removeAllData(bool includeInspectData = false);
|
void removeAllData(bool includeInspectData = false);
|
||||||
void resetValueCache();
|
void resetValueCache();
|
||||||
|
void resetWatchers();
|
||||||
void notifyUpdateStarted();
|
void notifyUpdateStarted();
|
||||||
void notifyUpdateFinished();
|
void notifyUpdateFinished();
|
||||||
void purgeOutdatedItems(const QSet<QByteArray> &inames);
|
void purgeOutdatedItems(const QSet<QByteArray> &inames);
|
||||||
|
|||||||
Reference in New Issue
Block a user