From db9c2f21eaf8952cf17a06db508879d61e6d007f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 2 Feb 2014 18:22:52 +0000 Subject: 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 --- src/client/ClientStore.cpp | 9 +++++++++ src/client/GraphModel.cpp | 38 ++++++++++++++++++++++---------------- 2 files changed, 31 insertions(+), 16 deletions(-) (limited to 'src') 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 port = dynamic_ptr_cast(top->second); + SPtr gpparent = dynamic_ptr_cast( + 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 o) assert(o->path().is_child_of(path())); assert(o->parent().get() == this); + SPtr pm = dynamic_ptr_cast(o); + if (pm) { + remove_arcs_on(pm); + remove_port(pm); + } + + SPtr bm = dynamic_ptr_cast(o); + if (bm) { + _signal_removed_block.emit(bm); + } + + return true; +} + +void +GraphModel::remove_arcs_on(SPtr 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 o) ++next; SPtr arc = dynamic_ptr_cast(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 pm = dynamic_ptr_cast(o); - if (pm) - remove_port(pm); - - SPtr bm = dynamic_ptr_cast(o); - if (bm) { - _signal_removed_block.emit(bm); - } - - return true; } void -- cgit v1.2.1