From d4785081aea2092ac7a98e1ef3ec6031574286e8 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 7 Jun 2011 02:44:16 +0000 Subject: Remove use of smart pointers in FlowCanvas entirely. Since FlowCanvas's containers own their children, there is no real benefit to using smart pointers for objects, though there is overhead. There are no longer any add or remove methods for containers, simply create (new) and destroy (delete) objects and things should work as expected. git-svn-id: http://svn.drobilla.net/lad/trunk/machina@3366 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/MachinaCanvas.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/gui/MachinaCanvas.cpp') diff --git a/src/gui/MachinaCanvas.cpp b/src/gui/MachinaCanvas.cpp index efb677f..2869c22 100644 --- a/src/gui/MachinaCanvas.cpp +++ b/src/gui/MachinaCanvas.cpp @@ -62,7 +62,7 @@ MachinaCanvas::node_clicked(WeakPtr item, GdkEventButton* event) if (last) { if (node != last) { - if (get_connection(last, node)) + if (get_connection(last.get(), node.get())) action_disconnect(last, node); else action_connect(last, node); @@ -112,7 +112,7 @@ MachinaCanvas::on_new_object(SharedPtr object) WeakPtr(view))); object->set_view(view); - add_item(view); + add_item(view.get()); } else if (type == "machina:Edge") { SharedPtr tail = _app->client_model()->find( @@ -126,11 +126,11 @@ MachinaCanvas::on_new_object(SharedPtr object) SharedPtr view( new EdgeView(*this, tail_view, head_view, object)); - tail_view->add_connection(view); - head_view->add_connection(view); + tail_view->add_connection(view.get()); + head_view->add_connection(view.get()); object->set_view(view); - add_connection(view); + add_connection(view.get()); } else { Raul::error << "Unknown object type " << type << std::endl; @@ -142,14 +142,11 @@ MachinaCanvas::on_erase_object(SharedPtr object) { const Raul::Atom& type = object->get(URIs::instance().rdf_type); if (type == "machina:Node") { - SharedPtr view = PtrCast(object->view()); - if (view) { - remove_item(view); - } + // Destruction of the view will remove from the canvas } else if (type == "machina:Edge") { SharedPtr view = PtrCast(object->view()); if (view) { - remove_connection(view->source().lock(), view->dest().lock()); + remove_connection(view->source(), view->dest()); } } else { Raul::error << "Unknown object type " << type << std::endl; -- cgit v1.2.1