+ XMLProperty const * prop_id = (*niter)->property ("id");
+ assert (prop_id);
+ PBD::ID id (prop_id->value ());
+
+ LocationList::const_iterator i = locations.begin();
+ while (i != locations.end () && (*i)->id() != id) {
+ ++i;
+ }
+
+ Location* loc;
+ if (i != locations.end()) {
+ /* we can re-use an old Location object */
+ loc = *i;
+
+ // changed locations will be updated by Locations::changed signal
+ loc->set_state (**niter, version);
+ } else {
+ loc = new Location (_session, **niter);
+ }
+
+ bool add = true;
+
+ if (version < 3000) {
+ /* look for old-style IsStart / IsEnd properties in this location;
+ if they are present, update the session_range_location accordingly
+ */
+ XMLProperty const * prop = (*niter)->property ("flags");
+ if (prop) {
+ string v = prop->value ();
+ while (1) {
+ string::size_type const c = v.find_first_of (',');
+ string const s = v.substr (0, c);
+ if (s == X_("IsStart")) {
+ session_range_location->set_start (loc->start(), true);
+ add = false;
+ } else if (s == X_("IsEnd")) {
+ session_range_location->set_end (loc->start(), true);
+ add = false;
+ }
+
+ if (c == string::npos) {
+ break;
+ }
+
+ v = v.substr (c + 1);
+ }
+ }
+ }
+
+ if (add) {
+ new_locations.push_back (loc);
+ }