From 74cc8f6067f9a7e6560e8abca9ec0a205597c028 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 27 Sep 2010 18:56:26 +0000 Subject: [PATCH] Fix multiple creation of identical automation tracks. Fixes #3482. git-svn-id: svn://localhost/ardour2/branches/3.0@7848 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/automation_time_axis.cc | 8 +++----- gtk2_ardour/route_time_axis.cc | 2 +- gtk2_ardour/route_time_axis.h | 2 +- gtk2_ardour/route_ui.cc | 11 ++++++++--- gtk2_ardour/route_ui.h | 3 ++- gtk2_ardour/time_axis_view.h | 2 +- 6 files changed, 16 insertions(+), 12 deletions(-) diff --git a/gtk2_ardour/automation_time_axis.cc b/gtk2_ardour/automation_time_axis.cc index 63c755139d..ba76f68e18 100644 --- a/gtk2_ardour/automation_time_axis.cc +++ b/gtk2_ardour/automation_time_axis.cc @@ -193,9 +193,7 @@ AutomationTimeAxisView::AutomationTimeAxisView (Session* s, boost::shared_ptrget_automation_child_xml_node ( - _control->parameter(), Stateful::loading_state_version - ); + XMLNode* xml_node = get_parent_with_state()->get_automation_child_xml_node (_control->parameter()); if (xml_node) { set_state (*xml_node, Stateful::loading_state_version); @@ -404,7 +402,7 @@ AutomationTimeAxisView::set_height (uint32_t h) TimeAxisView* state_parent = get_parent_with_state (); assert(state_parent); - XMLNode* xml_node = state_parent->get_automation_child_xml_node (_control->parameter(), Stateful::loading_state_version); + XMLNode* xml_node = state_parent->get_automation_child_xml_node (_control->parameter()); TimeAxisView::set_height (h); _base_rect->property_y2() = h; @@ -995,7 +993,7 @@ AutomationTimeAxisView::get_state_node () TimeAxisView* state_parent = get_parent_with_state (); if (state_parent) { - return state_parent->get_automation_child_xml_node (_control->parameter(), Stateful::loading_state_version); + return state_parent->get_automation_child_xml_node (_control->parameter()); } else { return 0; } diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc index 18ffce84ae..9a631f6941 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -2391,7 +2391,7 @@ RouteTimeAxisView::create_gain_automation_child (const Evoral::Parameter& param, error << "Route has no gain automation, unable to add automation track view." << endmsg; return; } - + gain_track.reset (new AutomationTimeAxisView (_session, _route, _route->amp(), c, _editor, diff --git a/gtk2_ardour/route_time_axis.h b/gtk2_ardour/route_time_axis.h index 53a9e47004..c3e122704d 100644 --- a/gtk2_ardour/route_time_axis.h +++ b/gtk2_ardour/route_time_axis.h @@ -117,7 +117,7 @@ public: /* make sure we get the right version of this */ - XMLNode* get_automation_child_xml_node (Evoral::Parameter param, int version) { return RouteUI::get_automation_child_xml_node (param, version); } + XMLNode* get_automation_child_xml_node (Evoral::Parameter param) { return RouteUI::get_automation_child_xml_node (param); } typedef std::map > AutomationTracks; AutomationTracks automation_tracks() { return _automation_tracks; } diff --git a/gtk2_ardour/route_ui.cc b/gtk2_ardour/route_ui.cc index 6a79ce0282..b69c6aaeeb 100644 --- a/gtk2_ardour/route_ui.cc +++ b/gtk2_ardour/route_ui.cc @@ -94,6 +94,7 @@ RouteUI::init () { self_destruct = true; xml_node = 0; + _xml_node_version = Stateful::current_state_version; mute_menu = 0; solo_menu = 0; sends_menu = 0; @@ -1266,12 +1267,15 @@ RouteUI::ensure_xml_node () if ((xml_node = _route->extra_xml ("GUI")) == 0) { xml_node = new XMLNode ("GUI"); _route->add_extra_xml (*xml_node); + } else { + /* the Route has one, so it must have been loaded */ + _xml_node_version = Stateful::loading_state_version; } } } XMLNode* -RouteUI::get_automation_child_xml_node (Evoral::Parameter param, int version) +RouteUI::get_automation_child_xml_node (Evoral::Parameter param) { ensure_xml_node (); @@ -1282,15 +1286,16 @@ RouteUI::get_automation_child_xml_node (Evoral::Parameter param, int version) for (iter = kids.begin(); iter != kids.end(); ++iter) { - if (version < 3000) { + if (_xml_node_version < 3000) { if ((*iter)->name() == sym) { return *iter; } } else { if ((*iter)->name() == AutomationTimeAxisView::state_node_name) { XMLProperty* type = (*iter)->property("automation-id"); - if (type && type->value() == sym) + if (type && type->value() == sym) { return *iter; + } } } } diff --git a/gtk2_ardour/route_ui.h b/gtk2_ardour/route_ui.h index 952b39a433..444b45147e 100644 --- a/gtk2_ardour/route_ui.h +++ b/gtk2_ardour/route_ui.h @@ -110,8 +110,9 @@ class RouteUI : public virtual AxisView XMLNode *xml_node; void ensure_xml_node (); + int _xml_node_version; - virtual XMLNode* get_automation_child_xml_node (Evoral::Parameter, int); + virtual XMLNode* get_automation_child_xml_node (Evoral::Parameter); bool mute_press(GdkEventButton*); bool mute_release(GdkEventButton*); diff --git a/gtk2_ardour/time_axis_view.h b/gtk2_ardour/time_axis_view.h index f01aa508ae..94d3bb16ce 100644 --- a/gtk2_ardour/time_axis_view.h +++ b/gtk2_ardour/time_axis_view.h @@ -206,7 +206,7 @@ class TimeAxisView : public virtual AxisView, public PBD::Stateful /* call this on the parent */ - virtual XMLNode* get_automation_child_xml_node (Evoral::Parameter, int) { return 0; } + virtual XMLNode* get_automation_child_xml_node (Evoral::Parameter) { return 0; } virtual LayerDisplay layer_display () const { return Overlaid; } virtual StreamView* view () const { return 0; }