From 75e0f5a023b5485a6f6efb3ebd6f2ae21f5a041b Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 30 Mar 2015 15:27:18 -0400 Subject: [PATCH] remove GUI object state when tracks/busses are removed. Not doing this results in accumulation of useless GUI object state which is never cleaned up. Taken from work by Grygorii Zharun. --- gtk2_ardour/automation_time_axis.cc | 1 + gtk2_ardour/axis_view.h | 6 ++++++ gtk2_ardour/gui_object.cc | 10 ++++++++++ gtk2_ardour/gui_object.h | 4 +++- gtk2_ardour/route_time_axis.cc | 2 ++ gtk2_ardour/route_ui.cc | 4 +++- 6 files changed, 25 insertions(+), 2 deletions(-) diff --git a/gtk2_ardour/automation_time_axis.cc b/gtk2_ardour/automation_time_axis.cc index 12876c1abb..b486d54840 100644 --- a/gtk2_ardour/automation_time_axis.cc +++ b/gtk2_ardour/automation_time_axis.cc @@ -285,6 +285,7 @@ AutomationTimeAxisView::AutomationTimeAxisView ( AutomationTimeAxisView::~AutomationTimeAxisView () { + cleanup_gui_properties (); delete _view; } diff --git a/gtk2_ardour/axis_view.h b/gtk2_ardour/axis_view.h index 7334945c2c..94f7708d90 100644 --- a/gtk2_ardour/axis_view.h +++ b/gtk2_ardour/axis_view.h @@ -70,6 +70,12 @@ class AxisView : public virtual Selectable, public PBD::ScopedConnectionList, pu property_hashtable.emplace(property_name, s.str()); gui_object_state().set_property (state_id(), property_name, value); } + + void cleanup_gui_properties () { + /* remove related property node from the GUI state */ + gui_object_state().remove_node (state_id()); + property_hashtable.clear (); + } bool marked_for_display () const; virtual bool set_marked_for_display (bool); diff --git a/gtk2_ardour/gui_object.cc b/gtk2_ardour/gui_object.cc index 3e21f82fa4..b00cd5ae54 100644 --- a/gtk2_ardour/gui_object.cc +++ b/gtk2_ardour/gui_object.cc @@ -71,6 +71,16 @@ GUIObjectState::get_or_add_node (const string& id) return get_or_add_node (&_state, id); } +/** Remove node with provided id. + * @param id property of Object node to look for. + */ + +void +GUIObjectState::remove_node (const std::string& id) +{ + _state.remove_nodes_and_delete(X_("id"), id ); +} + /** Get a string from our state. * @param id property of Object node to look for. * @param prop_name name of the Object property to return. diff --git a/gtk2_ardour/gui_object.h b/gtk2_ardour/gui_object.h index ee6d1cdf4c..aff025b2d5 100644 --- a/gtk2_ardour/gui_object.h +++ b/gtk2_ardour/gui_object.h @@ -47,12 +47,14 @@ public: s << val; child->add_property (prop_name.c_str(), s.str()); } - + std::list all_ids () const; static XMLNode* get_node (const XMLNode *, const std::string &); XMLNode* get_or_add_node (const std::string &); static XMLNode* get_or_add_node (XMLNode *, const std::string &); + + void remove_node (const std::string& id); private: XMLNode _state; diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc index 502e24d8a0..7d0883775d 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -323,6 +323,8 @@ RouteTimeAxisView::set_route (boost::shared_ptr rt) RouteTimeAxisView::~RouteTimeAxisView () { + cleanup_gui_properties (); + for (list::iterator i = processor_automation.begin(); i != processor_automation.end(); ++i) { delete *i; } diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index 118306c29c..f038ead366 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -87,9 +87,11 @@ RouteUI::RouteUI (ARDOUR::Session* sess) RouteUI::~RouteUI() { + gui_object_state().remove_node(route_state_id()); + _route.reset (); /* drop reference to route, so that it can be cleaned up */ route_connections.drop_connections (); - + delete solo_menu; delete mute_menu; delete sends_menu;