summaryrefslogtreecommitdiffstats
path: root/src/object-set.cpp
diff options
context:
space:
mode:
authorFriedrich Beckmann <friedrich.beckmann@gmx.de>2017-10-04 09:35:10 +0000
committerFriedrich Beckmann <friedrich.beckmann@gmx.de>2017-10-04 09:35:10 +0000
commita920a212fa3436801f27f75051ab47e36c21e3a2 (patch)
tree904c9fb9d56f106c6d45be4b598ed29bf812f239 /src/object-set.cpp
parentFix bug: crash - iterator corrupted by removing objects from container (diff)
downloadinkscape-a920a212fa3436801f27f75051ab47e36c21e3a2.tar.gz
inkscape-a920a212fa3436801f27f75051ab47e36c21e3a2.zip
selection clear: First disconnect, then clear
As proposed by Marc, the objects are first disconnected and then all elements are removed from the container via container.clear. This also avoids the corruption of the iterator as the container is not modified during the iterations.
Diffstat (limited to 'src/object-set.cpp')
-rw-r--r--src/object-set.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/object-set.cpp b/src/object-set.cpp
index 55da22bdf..36ddac350 100644
--- a/src/object-set.cpp
+++ b/src/object-set.cpp
@@ -124,11 +124,9 @@ void ObjectSet::_add(SPObject *object) {
}
void ObjectSet::_clear() {
- MultiIndexContainer::iterator it = _container.begin();
- while (it != _container.end()){
- _disconnect(*it);
- it = _container.erase(it);
- }
+ for (auto object: _container)
+ _disconnect(object);
+ _container.clear();
}
SPObject *ObjectSet::_getMutualAncestor(SPObject *object) {