diff options
author | David Robillard <d@drobilla.net> | 2014-02-02 18:22:52 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2014-02-02 18:22:52 +0000 |
commit | db9c2f21eaf8952cf17a06db508879d61e6d007f (patch) | |
tree | 1003ab733e27a2a60e8b167f922909564f12bf23 /src/client | |
parent | 104aa8285df2b827fcbfe08b83ef931628976d90 (diff) | |
download | ingen-db9c2f21eaf8952cf17a06db508879d61e6d007f.tar.gz ingen-db9c2f21eaf8952cf17a06db508879d61e6d007f.tar.bz2 ingen-db9c2f21eaf8952cf17a06db508879d61e6d007f.zip |
Remove client-side arcs in parent graph when ports are deleted (fix #960).
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5332 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/ClientStore.cpp | 9 | ||||
-rw-r--r-- | src/client/GraphModel.cpp | 38 |
2 files changed, 31 insertions, 16 deletions
diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index a3fc60aa..80f210fe 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -118,6 +118,15 @@ ClientStore::remove_object(const Raul::Path& path) // Remove object from parent model if applicable if (object->parent()) { + SPtr<PortModel> port = dynamic_ptr_cast<PortModel>(top->second); + SPtr<GraphModel> gpparent = dynamic_ptr_cast<GraphModel>( + object->parent()->parent()); + if (port && gpparent) { + /* Port on a block in a graph (probably on a subgraph), + remove any connections in the parent's parent graph. */ + gpparent->remove_arcs_on(port); + } + object->parent()->remove_child(object); } } diff --git a/src/client/GraphModel.cpp b/src/client/GraphModel.cpp index 764c3b75..cebaa759 100644 --- a/src/client/GraphModel.cpp +++ b/src/client/GraphModel.cpp @@ -50,6 +50,23 @@ GraphModel::remove_child(SPtr<ObjectModel> o) assert(o->path().is_child_of(path())); assert(o->parent().get() == this); + SPtr<PortModel> pm = dynamic_ptr_cast<PortModel>(o); + if (pm) { + remove_arcs_on(pm); + remove_port(pm); + } + + SPtr<BlockModel> bm = dynamic_ptr_cast<BlockModel>(o); + if (bm) { + _signal_removed_block.emit(bm); + } + + return true; +} + +void +GraphModel::remove_arcs_on(SPtr<PortModel> p) +{ // Remove any connections which referred to this object, // since they can't possibly exist anymore for (Arcs::iterator j = _arcs.begin(); j != _arcs.end();) { @@ -57,26 +74,15 @@ GraphModel::remove_child(SPtr<ObjectModel> o) ++next; SPtr<ArcModel> arc = dynamic_ptr_cast<ArcModel>(j->second); - if (arc->tail_path().parent() == o->path() - || arc->tail_path() == o->path() - || arc->head_path().parent() == o->path() - || arc->head_path() == o->path()) { + if (arc->tail_path().parent() == p->path() + || arc->tail_path() == p->path() + || arc->head_path().parent() == p->path() + || arc->head_path() == p->path()) { _signal_removed_arc.emit(arc); - _arcs.erase(j); // cuts our reference + _arcs.erase(j); // Cuts our reference } j = next; } - - SPtr<PortModel> pm = dynamic_ptr_cast<PortModel>(o); - if (pm) - remove_port(pm); - - SPtr<BlockModel> bm = dynamic_ptr_cast<BlockModel>(o); - if (bm) { - _signal_removed_block.emit(bm); - } - - return true; } void |