From eac59697740e943f2e2c7a2382bc3399e7aa7cfc Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 3 Jun 2011 18:14:32 +0000 Subject: Remove use of boost::enable_shared_from_this. Instead, just store a pointer to the containing canvas in Items, since it should not be possible for an Item to outlive its containing Canvas anyway. Shrinks Item memory overhead a tad and gives a minor performance boost as an added bonus. git-svn-id: http://svn.drobilla.net/lad/trunk/machina@3354 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/EdgeView.cpp | 2 +- src/gui/EdgeView.hpp | 2 +- src/gui/MachinaCanvas.cpp | 4 ++-- src/gui/NodeView.cpp | 6 +++--- src/gui/NodeView.hpp | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/gui/EdgeView.cpp b/src/gui/EdgeView.cpp index a8a9f92..b422e5e 100644 --- a/src/gui/EdgeView.cpp +++ b/src/gui/EdgeView.cpp @@ -62,7 +62,7 @@ inline static uint32_t edge_color(float prob) using namespace FlowCanvas; -EdgeView::EdgeView(SharedPtr canvas, +EdgeView::EdgeView(Canvas& canvas, SharedPtr src, SharedPtr dst, SharedPtr edge) diff --git a/src/gui/EdgeView.hpp b/src/gui/EdgeView.hpp index fcdbfa4..30c5b75 100644 --- a/src/gui/EdgeView.hpp +++ b/src/gui/EdgeView.hpp @@ -30,7 +30,7 @@ class EdgeView : public FlowCanvas::Connection , public Machina::Client::ClientObject::View { public: - EdgeView(SharedPtr canvas, + EdgeView(FlowCanvas::Canvas& canvas, SharedPtr src, SharedPtr dst, SharedPtr edge); diff --git a/src/gui/MachinaCanvas.cpp b/src/gui/MachinaCanvas.cpp index b65a4bb..efb677f 100644 --- a/src/gui/MachinaCanvas.cpp +++ b/src/gui/MachinaCanvas.cpp @@ -100,7 +100,7 @@ MachinaCanvas::on_new_object(SharedPtr object) const Raul::Atom& type = object->get(uris.rdf_type); if (type == "machina:Node") { SharedPtr view( - new NodeView(_app->window(), shared_from_this(), object, + new NodeView(_app->window(), *this, object, object->get(uris.machina_canvas_x).get_float(), object->get(uris.machina_canvas_y).get_float())); @@ -124,7 +124,7 @@ MachinaCanvas::on_new_object(SharedPtr object) SharedPtr head_view = PtrCast(head->view()); SharedPtr view( - new EdgeView(shared_from_this(), tail_view, head_view, object)); + new EdgeView(*this, tail_view, head_view, object)); tail_view->add_connection(view); head_view->add_connection(view); diff --git a/src/gui/NodeView.cpp b/src/gui/NodeView.cpp index 964fc04..e417ffa 100644 --- a/src/gui/NodeView.cpp +++ b/src/gui/NodeView.cpp @@ -30,7 +30,7 @@ using namespace std; using Machina::URIs; NodeView::NodeView(Gtk::Window* window, - SharedPtr canvas, + FlowCanvas::Canvas& canvas, SharedPtr node, double x, double y) @@ -64,7 +64,7 @@ void NodeView::handle_click(GdkEventButton* event) { if (event->state & GDK_CONTROL_MASK) { - SharedPtr canvas = PtrCast(_canvas.lock()); + MachinaCanvas* canvas = dynamic_cast(_canvas); if (event->button == 1) { canvas->app()->controller()->set_property( _node->id(), @@ -156,7 +156,7 @@ NodeView::on_property(Machina::URIInt key, const Raul::Atom& value) } } else if (key == URIs::instance().machina_enter_action) { const uint64_t action_id = value.get_int32(); - SharedPtr canvas = PtrCast(_canvas.lock()); + MachinaCanvas* canvas = dynamic_cast(_canvas); _enter_action_connection.disconnect(); _enter_action = canvas->app()->client_model()->find(action_id); _enter_action_connection = _enter_action->signal_property.connect( diff --git a/src/gui/NodeView.hpp b/src/gui/NodeView.hpp index 0736af9..29ceb9b 100644 --- a/src/gui/NodeView.hpp +++ b/src/gui/NodeView.hpp @@ -29,7 +29,7 @@ class NodeView , public Machina::Client::ClientObject::View { public: NodeView(Gtk::Window* window, - SharedPtr canvas, + Canvas& canvas, SharedPtr node, double x, double y); -- cgit v1.2.1