From eb10d32d8b59f2158ba64ba55e310ba0f5f24170 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 14 May 2008 23:31:15 +0000 Subject: Fix clear patch command (ticket #18). Potential destruction race/leak fixes. More thorough thread assertions on graph object methods. git-svn-id: http://svn.drobilla.net/lad/ingen@1207 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/engine/ObjectStore.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/libs/engine/ObjectStore.cpp') diff --git a/src/libs/engine/ObjectStore.cpp b/src/libs/engine/ObjectStore.cpp index e8fa3f4d..4497360a 100644 --- a/src/libs/engine/ObjectStore.cpp +++ b/src/libs/engine/ObjectStore.cpp @@ -149,5 +149,43 @@ ObjectStore::remove(Objects::iterator object) } } + +/** Remove all children of an object from the store. + * + * Returned is a vector containing all descendants of the object removed + * in lexicographically sorted order by Path. + */ +SharedPtr< Table > > +ObjectStore::remove_children(const Path& path) +{ + return remove_children(_objects.find(path)); +} + + +/** Remove all children of an object from the store. + * + * Returned is a vector containing all descendants of the object removed + * in lexicographically sorted order by Path. + */ +SharedPtr< Table > > +ObjectStore::remove_children(Objects::iterator object) +{ + if (object != _objects.end()) { + Objects::iterator descendants_end = _objects.find_descendants_end(object); + + if (descendants_end != object) { + Objects::iterator first_child = object; + ++first_child; + return _objects.yank(first_child, descendants_end); + } + + } else { + cerr << "[ObjectStore] WARNING: Removing children of " << object->first << " failed." << endl; + return SharedPtr(); + } + + return SharedPtr(); +} + } // namespace Ingen -- cgit v1.2.1