From b3f88df41df29f8a20e7ddf6fd8b83100a75740d Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 19 Mar 2015 12:42:53 +0100 Subject: Debugger: Remove most remaining occurrences of WatchData ... in WatchHandler and DebuggerEngine interface. Adjust using code. Change-Id: I6371f3e96ba46a783e23a5767cdde24a10d3fce7 Reviewed-by: Christian Stenger Reviewed-by: hjk --- src/plugins/debugger/cdb/cdbengine.cpp | 41 +++++++++++++++++----------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'src/plugins/debugger/cdb/cdbengine.cpp') diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 657972e899..a4535f10ef 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -974,46 +974,47 @@ static inline bool isWatchIName(const QByteArray &iname) return iname.startsWith("watch"); } -void CdbEngine::updateWatchData(const WatchData &dataIn) +void CdbEngine::updateWatchItem(WatchItem *item) { if (debug || debugLocals || debugWatches) qDebug("CdbEngine::updateWatchData() %dms accessible=%d %s: %s", elapsedLogTime(), m_accessible, stateName(state()), - qPrintable(dataIn.toString())); + qPrintable(item->toString())); if (!m_accessible) // Add watch data while running? return; // New watch item? - if (dataIn.isWatcher() && dataIn.isValueNeeded()) { + if (item->isWatcher() && item->isValueNeeded()) { QByteArray args; ByteArrayInputStream str(args); - str << dataIn.iname << " \"" << dataIn.exp << '"'; + WatchData data = *item; // Don't pass pointers to async functions. + str << data.iname << " \"" << data.exp << '"'; postExtensionCommand("addwatch", args, 0, - [this, dataIn](const CdbResponse &r) { handleAddWatch(r, dataIn); }); + [this, data](const CdbResponse &r) { handleAddWatch(r, data); }); return; } - if (!dataIn.hasChildren && !dataIn.isValueNeeded()) { - WatchData data = dataIn; - data.setAllUnneeded(); - watchHandler()->insertData(data); - return; + if (item->wantsChildren || item->isValueNeeded()) { + updateLocalVariable(item->iname); + } else { + item->setAllUnneeded(); + item->update(); } - updateLocalVariable(dataIn.iname); } -void CdbEngine::handleAddWatch(const CdbResponse &response, WatchData item) +void CdbEngine::handleAddWatch(const CdbResponse &response, WatchData data) { if (debugWatches) - qDebug() << "handleAddWatch ok=" << response.success << item.iname; + qDebug() << "handleAddWatch ok=" << response.success << data.iname; if (response.success) { - updateLocalVariable(item.iname); + updateLocalVariable(data.iname); } else { - item.setError(tr("Unable to add expression")); - watchHandler()->insertData(item); + auto item = new WatchItem(data); + item->setError(tr("Unable to add expression")); + watchHandler()->insertItem(item); showMessage(QString::fromLatin1("Unable to add watch item \"%1\"/\"%2\": %3"). - arg(QString::fromLatin1(item.iname), QString::fromLatin1(item.exp), + arg(QString::fromLatin1(data.iname), QString::fromLatin1(data.exp), QString::fromLocal8Bit(response.errorMessage)), LogError); } } @@ -1269,7 +1270,7 @@ static inline bool isAsciiWord(const QString &s) return true; } -void CdbEngine::assignValueInDebugger(const WatchData *w, const QString &expr, const QVariant &value) +void CdbEngine::assignValueInDebugger(WatchItem *w, const QString &expr, const QVariant &value) { if (debug) qDebug() << "CdbEngine::assignValueInDebugger" << w->iname << expr << value; @@ -1871,13 +1872,13 @@ void CdbEngine::handleLocals(const CdbResponse &response, bool newFrame) QSet toDelete; if (newFrame) { foreach (WatchItem *item, handler->model()->treeLevelItems(2)) - toDelete.insert(item->d.iname); + toDelete.insert(item->iname); } foreach (const GdbMi &child, all.children()) { WatchItem *item = new WatchItem(child); handler->insertItem(item); - toDelete.remove(item->d.iname); + toDelete.remove(item->iname); } handler->purgeOutdatedItems(toDelete); -- cgit v1.2.1