From 4ee3f2666d79256a69ed66d511cbe64b83e4de5f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 14 Mar 2016 19:03:33 -0400 Subject: Remove arcs in client store on object deletion Fix #1120. --- src/client/ClientStore.cpp | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index 12674981..7afa4aee 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -106,28 +106,30 @@ ClientStore::remove_object(const Raul::Path& path) SPtr object = dynamic_ptr_cast(top->second); + // Remove object and any adjacent arcs from parent if applicable + if (object && object->parent()) { + SPtr port = dynamic_ptr_cast(object); + if (port && dynamic_ptr_cast(port->parent())) { + disconnect_all(port->parent()->path(), path); + if (port->parent()->parent()) { + disconnect_all(port->parent()->parent()->path(), path); + } + } else if (port && port->parent()->parent()) { + disconnect_all(port->parent()->parent()->path(), path); + } else { + disconnect_all(object->parent()->path(), path); + } + + object->parent()->remove_child(object); + } + // Remove the object and all its descendants Objects removed; remove(top, removed); - // Notify everything that needs to know this object is going away + // Notify everything that needs to know this object has been removed if (object) { - // Notify the program this object is going away object->signal_destroyed().emit(); - - // Remove object from parent model if applicable - if (object->parent()) { - SPtr port = dynamic_ptr_cast(object); - 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); - } } return object; -- cgit v1.2.1