Debugger: Simplify removal of outdated L&E items

This removes the need of bookkeeping on the engine side. It's
basically a kind of mark-and-sweep: On update begin mark items
that are expected to change as outdated, while data arrives, undo
that marking, and update end remove all remaining marked items.

Change-Id: I739b84869033d511d5c9a80605c079e87ef4f6a7
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
hjk
2015-07-06 09:46:08 +02:00
parent 1587c171d6
commit d48ac14fba
10 changed files with 55 additions and 42 deletions

View File

@@ -1221,8 +1221,20 @@ void WatchHandler::resetWatchers()
loadSessionData();
}
void WatchHandler::notifyUpdateStarted()
void WatchHandler::notifyUpdateStarted(const QList<QByteArray> &inames)
{
auto marker = [](TreeItem *it) { static_cast<WatchItem *>(it)->outdated = true; };
if (inames.isEmpty()) {
foreach (auto item, m_model->itemsAtLevel<WatchItem *>(2))
item->walkTree(marker);
} else {
foreach (auto iname, inames) {
if (WatchItem *item = m_model->findItem(iname))
item->walkTree(marker);
}
}
m_model->m_requestUpdateTimer.start(80);
m_model->m_contentsValid = false;
updateWatchersWindow();
@@ -1230,25 +1242,32 @@ void WatchHandler::notifyUpdateStarted()
void WatchHandler::notifyUpdateFinished()
{
struct OutDatedItemsFinder : public TreeItemVisitor
{
bool preVisit(TreeItem *item)
{
auto watchItem = static_cast<WatchItem *>(item);
if (level() <= 1 || !watchItem->outdated)
return true;
toRemove.append(watchItem);
return false;
}
QList<WatchItem *> toRemove;
} finder;
m_model->root()->walkTree(&finder);
foreach (auto item, finder.toRemove)
delete m_model->takeItem(item);
m_model->m_contentsValid = true;
updateWatchersWindow();
m_model->reexpandItems();
m_model->m_requestUpdateTimer.stop();
emit m_model->updateFinished();
}
void WatchHandler::purgeOutdatedItems(const QSet<QByteArray> &inames)
{
foreach (const QByteArray &iname, inames) {
WatchItem *item = findItem(iname);
delete m_model->takeItem(item);
}
m_model->layoutChanged();
m_model->reexpandItems();
m_model->m_contentsValid = true;
updateWatchersWindow();
}
void WatchHandler::removeItemByIName(const QByteArray &iname)
{
WatchItem *item = m_model->findItem(iname);