diff options
author | hjk <hjk@theqtcompany.com> | 2015-03-18 13:28:45 +0100 |
---|---|---|
committer | hjk <hjk@theqtcompany.com> | 2015-03-19 06:58:51 +0000 |
commit | 13d425b972cfa25a9f87e326cec22028a4bf0f42 (patch) | |
tree | fc676fc836037e0c707b19ab6bcf71a04b571a9a | |
parent | 4514dbfd8c18db8482ea449635ddb16d72325b5a (diff) | |
download | qt-creator-13d425b972cfa25a9f87e326cec22028a4bf0f42.tar.gz |
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>
-rw-r--r-- | src/plugins/debugger/debuggerplugin.cpp | 2 | ||||
-rw-r--r-- | src/plugins/debugger/watchhandler.cpp | 77 | ||||
-rw-r--r-- | src/plugins/debugger/watchhandler.h | 1 |
3 files changed, 31 insertions, 49 deletions
diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 6796198153..aff64de8f8 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -1820,6 +1820,8 @@ void DebuggerPluginPrivate::connectEngine(DebuggerEngine *engine) m_watchersView->setModel(engine->watchModel()); m_inspectorView->setModel(engine->watchModel()); + engine->watchHandler()->resetWatchers(); + mainWindow()->setEngineDebugLanguages(engine->startParameters().languages); } diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index abb86fc645..cb9dcf77a0 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -863,22 +863,7 @@ bool WatchModel::setData(const QModelIndex &idx, const QVariant &value, int role case Qt::EditRole: switch (idx.column()) { case 0: { - QByteArray exp = value.toByteArray(); - 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(); + m_handler->watchExpression(value.toString()); break; } 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 { QTC_ASSERT(model(), return Qt::ItemFlags()); - if (!watchModel()->contentIsValid() && !d.isInspect()) - return Qt::ItemFlags(); + DebuggerEngine *engine = watchModel()->engine(); + QTC_ASSERT(engine, return Qt::ItemFlags()); + const DebuggerState state = engine->state(); // Enabled, editable, selectable, checkable, and can be used both as the // 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 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 (state != InferiorStopOk + && state != DebuggerNotReady + && state != DebuggerFinished + && !engine->hasCapability(AddWatcherWhileRunningCapability)) + return Qt::ItemFlags(); if (column == 0 && d.iname.count('.') == 1) return editable; // Watcher names are editable. @@ -950,6 +934,8 @@ Qt::ItemFlags WatchItem::flags(int column) const return editable; // Watcher values are sometimes editable. } } else if (d.isLocal()) { + if (state != InferiorStopOk && !engine->hasCapability(AddWatcherWhileRunningCapability)) + return Qt::ItemFlags(); if (column == 1 && d.valueEditable) return editable; // Locals values are sometimes editable. } else if (d.isInspect()) { @@ -1182,6 +1168,7 @@ void WatchHandler::cleanup() { m_model->m_expandedINames.clear(); theWatcherNames.remove(QByteArray()); + saveWatchers(); m_model->reinitialize(); emit m_model->updateFinished(); m_separatedView->hide(); @@ -1250,16 +1237,12 @@ void WatchModel::reexpandItems() void WatchHandler::insertData(const WatchData &data) { m_model->insertDataItem(data); - m_contentsValid = true; - updateWatchersWindow(); } void WatchHandler::insertDataList(const QList<WatchData> &list) { for (int i = 0, n = list.size(); i != n; ++i) m_model->insertDataItem(list.at(i)); - m_contentsValid = true; - updateWatchersWindow(); } void WatchHandler::removeAllData(bool includeInspectData) @@ -1278,13 +1261,22 @@ void WatchHandler::resetValueCache() }); } +void WatchHandler::resetWatchers() +{ + loadSessionData(); +} + void WatchHandler::notifyUpdateStarted() { m_model->m_requestUpdateTimer.start(80); + m_contentsValid = false; + updateWatchersWindow(); } void WatchHandler::notifyUpdateFinished() { + m_contentsValid = true; + updateWatchersWindow(); m_model->m_requestUpdateTimer.stop(); emit m_model->updateFinished(); } @@ -1323,25 +1315,19 @@ QByteArray WatchHandler::watcherName(const QByteArray &exp) 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. - if (theWatcherNames.value(exp.toLatin1())) + QByteArray exp = exp0.toLatin1(); + if (exp.isEmpty() || theWatcherNames.contains(exp)) return; - // FIXME: 'exp' can contain illegal characters - exp.replace(QLatin1Char('#'), QString()); + theWatcherNames[exp] = theWatcherCount++; WatchData data; - data.exp = exp.toLatin1(); - data.name = name.isEmpty() ? exp : name; - theWatcherNames[data.exp] = theWatcherCount++; + data.exp = exp; + data.name = name.isEmpty() ? exp0 : name; + data.iname = watcherName(exp); saveWatchers(); - if (exp.isEmpty()) - data.setAllUnneeded(); - data.iname = watcherName(data.exp); if (m_engine->state() == DebuggerNotReady) { data.setAllUnneeded(); data.setValue(QString(QLatin1Char(' '))); @@ -1471,14 +1457,8 @@ void WatchHandler::updateWatchersWindow() emit m_model->columnAdjustmentRequested(); // Force show/hide of watchers and return view. - static int previousShowWatch = -1; - static int previousShowReturn = -1; - int showWatch = !m_model->m_watchRoot->children().isEmpty(); + int showWatch = !theWatcherNames.isEmpty(); int showReturn = !m_model->m_returnRoot->children().isEmpty(); - if (showWatch == previousShowWatch && showReturn == previousShowReturn) - return; - previousShowWatch = showWatch; - previousShowReturn = showReturn; Internal::updateWatchersWindow(showWatch, showReturn); } @@ -1764,7 +1744,6 @@ void WatchHandler::editTypeFormats(bool includeLocals, const QByteArray &iname) void WatchHandler::scheduleResetLocation() { m_contentsValid = false; - //m_contentsValid = true; // FIXME m_resetLocationScheduled = true; } diff --git a/src/plugins/debugger/watchhandler.h b/src/plugins/debugger/watchhandler.h index 1faaabb542..e99e449319 100644 --- a/src/plugins/debugger/watchhandler.h +++ b/src/plugins/debugger/watchhandler.h @@ -244,6 +244,7 @@ public: void removeItemByIName(const QByteArray &iname); void removeAllData(bool includeInspectData = false); void resetValueCache(); + void resetWatchers(); void notifyUpdateStarted(); void notifyUpdateFinished(); void purgeOutdatedItems(const QSet<QByteArray> &inames); |