diff options
author | David Robillard <d@drobilla.net> | 2011-06-03 18:14:32 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-06-03 18:14:32 +0000 |
commit | eac59697740e943f2e2c7a2382bc3399e7aa7cfc (patch) | |
tree | c888aeef713e788d93a1c370aeda727378007def | |
parent | 890a0f771f0f2b2996525d0f8ccf72d93c7bdc6b (diff) | |
download | machina-eac59697740e943f2e2c7a2382bc3399e7aa7cfc.tar.gz machina-eac59697740e943f2e2c7a2382bc3399e7aa7cfc.tar.bz2 machina-eac59697740e943f2e2c7a2382bc3399e7aa7cfc.zip |
Remove use of boost::enable_shared_from_this<Canvas>.
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
-rw-r--r-- | src/gui/EdgeView.cpp | 2 | ||||
-rw-r--r-- | src/gui/EdgeView.hpp | 2 | ||||
-rw-r--r-- | src/gui/MachinaCanvas.cpp | 4 | ||||
-rw-r--r-- | src/gui/NodeView.cpp | 6 | ||||
-rw-r--r-- | src/gui/NodeView.hpp | 2 |
5 files changed, 8 insertions, 8 deletions
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> canvas, +EdgeView::EdgeView(Canvas& canvas, SharedPtr<NodeView> src, SharedPtr<NodeView> dst, SharedPtr<Machina::Client::ClientObject> 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<FlowCanvas::Canvas> canvas, + EdgeView(FlowCanvas::Canvas& canvas, SharedPtr<NodeView> src, SharedPtr<NodeView> dst, SharedPtr<Machina::Client::ClientObject> 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<Client::ClientObject> object) const Raul::Atom& type = object->get(uris.rdf_type); if (type == "machina:Node") { SharedPtr<NodeView> 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<Client::ClientObject> object) SharedPtr<NodeView> head_view = PtrCast<NodeView>(head->view()); SharedPtr<EdgeView> 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<FlowCanvas::Canvas> canvas, + FlowCanvas::Canvas& canvas, SharedPtr<Machina::Client::ClientObject> node, double x, double y) @@ -64,7 +64,7 @@ void NodeView::handle_click(GdkEventButton* event) { if (event->state & GDK_CONTROL_MASK) { - SharedPtr<MachinaCanvas> canvas = PtrCast<MachinaCanvas>(_canvas.lock()); + MachinaCanvas* canvas = dynamic_cast<MachinaCanvas*>(_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<MachinaCanvas> canvas = PtrCast<MachinaCanvas>(_canvas.lock()); + MachinaCanvas* canvas = dynamic_cast<MachinaCanvas*>(_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<FlowCanvas::Canvas> canvas, + Canvas& canvas, SharedPtr<Machina::Client::ClientObject> node, double x, double y); |