From a920a212fa3436801f27f75051ab47e36c21e3a2 Mon Sep 17 00:00:00 2001 From: Friedrich Beckmann Date: Wed, 4 Oct 2017 11:35:10 +0200 Subject: 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. --- src/object-set.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/object-set.cpp') 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) { -- cgit v1.2.3