diff options
author | David Robillard <d@drobilla.net> | 2008-05-14 23:31:15 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-05-14 23:31:15 +0000 |
commit | eb10d32d8b59f2158ba64ba55e310ba0f5f24170 (patch) | |
tree | d67944c6ada3369ba988cee4bd86ca24ee9de703 /src/libs/client/Store.cpp | |
parent | 5fc6f5df54a2650c4a53f04ee38cfebec0a515e1 (diff) | |
download | ingen-eb10d32d8b59f2158ba64ba55e310ba0f5f24170.tar.gz ingen-eb10d32d8b59f2158ba64ba55e310ba0f5f24170.tar.bz2 ingen-eb10d32d8b59f2158ba64ba55e310ba0f5f24170.zip |
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
Diffstat (limited to 'src/libs/client/Store.cpp')
-rw-r--r-- | src/libs/client/Store.cpp | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/src/libs/client/Store.cpp b/src/libs/client/Store.cpp index 24a30064..60c03049 100644 --- a/src/libs/client/Store.cpp +++ b/src/libs/client/Store.cpp @@ -60,7 +60,6 @@ Store::clear() { _objects.clear(); _plugins.clear(); - } @@ -352,8 +351,8 @@ Store::destruction_event(const Path& path) removed.reset(); - //cerr << "Store removed object " << path - // << ", count: " << removed.use_count(); + /*cerr << "Store removed object " << path + << ", count: " << removed.use_count();*/ } void @@ -482,11 +481,28 @@ Store::patch_polyphony_event(const Path& path, uint32_t poly) void Store::patch_cleared_event(const Path& path) { - SharedPtr<PatchModel> patch = PtrCast<PatchModel>(object(path)); - if (patch) - for (ObjectModel::const_iterator i = patch->children_begin(); i != patch->children_end(); ++i) - if (i->second->graph_parent() == patch.get()) - destruction_event(i->second->path()); + Objects::iterator i = _objects.find(path); + if (i != _objects.end()) { + assert((*i).second->path() == path); + SharedPtr<PatchModel> patch = PtrCast<PatchModel>(i->second); + + Objects::iterator first_descendant = i; + ++first_descendant; + Objects::iterator descendants_end = _objects.find_descendants_end(i); + SharedPtr< Table<Path, SharedPtr<Shared::GraphObject> > > removed + = _objects.yank(first_descendant, descendants_end); + + for (Objects::iterator i = removed->begin(); i != removed->end(); ++i) { + SharedPtr<ObjectModel> model = PtrCast<ObjectModel>(i->second); + assert(model); + model->signal_destroyed.emit(); + if (model->parent() == patch) + patch->remove_child(model); + } + + } else { + cerr << "[Store] Unable to find patch " << path << " to clear." << endl; + } } @@ -498,7 +514,6 @@ Store::variable_change_event(const Path& subject_path, const string& predicate, if (!value) { cerr << "ERROR: variable '" << predicate << "' has no type" << endl; } else if (subject) { - cerr << "Set variable '" << predicate << "' with type " << (int)value.type() << endl; subject->set_variable(predicate, value); } else { add_variable_orphan(subject_path, predicate, value); |