diff options
-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 |