From 98ad20529bb8b05ee727f0eaf9b925922fdb2a63 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 27 Jan 2022 15:36:01 -0700 Subject: [PATCH] fix loading of regions in older session files In session file formats earlier than 7000, region position and length are stored in distinct XML node properties. For 7000 or later, both position and length are part of the "length" member. Fix reloading this by noting session file format and loading position and length more explicitly --- libs/ardour/region.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc index b548be3043..691b343b2c 100644 --- a/libs/ardour/region.cc +++ b/libs/ardour/region.cc @@ -1314,7 +1314,7 @@ Region::set_state (const XMLNode& node, int version) } int -Region::_set_state (const XMLNode& node, int /*version*/, PropertyChange& what_changed, bool send) +Region::_set_state (const XMLNode& node, int version, PropertyChange& what_changed, bool send) { Temporal::BBT_Time bbt_time; @@ -1322,6 +1322,20 @@ Region::_set_state (const XMLNode& node, int /*version*/, PropertyChange& what_c what_changed = set_values (node); + if (version < 7000) { + + /* Older versions saved position and length as separate XML + * node properties. + */ + + samplepos_t p; + samplepos_t l; + + if (node.get_property (X_("position"), p) && node.get_property (X_("length"), l)) { + _length = timecnt_t (l, timepos_t (p)); + } + } + /* Regions derived from "Destructive/Tape" mode tracks in earlier * versions will have their length set to an extremely large value * (essentially the maximum possible length of a file). Detect this