summaryrefslogtreecommitdiff
path: root/src/core/dom
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2014-11-03 15:29:06 +0000
committerandreas <andreas@daaaf23c-2e50-4459-9457-1e69db5a47bf>2014-11-03 15:29:06 +0000
commita0145fffef9a8f220b8fd852d8f78656386881f3 (patch)
tree97c404b52ad706060781f2ea74a75ef20ba4bf28 /src/core/dom
parent126fa80b6d68bcc16cdc117d216a4fc01f9291d3 (diff)
fixed node purging
git-svn-id: file:///var/local/svn/basicwriter@96 daaaf23c-2e50-4459-9457-1e69db5a47bf
Diffstat (limited to 'src/core/dom')
-rw-r--r--src/core/dom/Node.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/core/dom/Node.cpp b/src/core/dom/Node.cpp
index dcf4261..8df0787 100644
--- a/src/core/dom/Node.cpp
+++ b/src/core/dom/Node.cpp
@@ -257,13 +257,21 @@ void NodeManager::purgeDeleted()
{
// Perform the actual deletion if the recursion level is zero
if (deletionRecursionDepth == 0 && !deleted.empty()) {
+ // Increment the recursion depth so this function does not get called
+ // again while deleting nodes
ScopedIncrement incr{deletionRecursionDepth};
- for (Node *n : deleted) {
+
+ // Deleting nodes might add new nodes to the deleted list, thus the
+ // iterator would get invalid and we have to use this awkward
+ // construction
+ while (!deleted.empty()) {
+ auto it = deleted.begin();
+ Node *n = *it;
+ deleted.erase(it);
marked.erase(n);
nodes.erase(n);
delete n;
}
- deleted.clear();
}
}