summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2020-02-28 06:35:33 +0100
committerRobin Gareus <robin@gareus.org>2020-02-28 06:35:33 +0100
commita4851954536bb7706fbf25fcf44242cd5454b5fd (patch)
tree3dbed498b45cb8275c6fbda85379db27a8bda7cc
parent016eaddad72a369022d1f7f29ecbbbed17bef3f5 (diff)
Ensure that regions have sources when saving
Otherwise this will lead to a corrupt state: ERROR: Session: XMLNode describing a AudioRegion references an unknown source id ERROR: Session: cannot create Region from XML description. Can not load state for region ERROR: Playlist: cannot create region from XML and a track without playlist is created, resulting in a later crash. Eventually SessionPlaylists::load() needs to handle this gracefully, but this should help catch cases causing the actual issue.
-rw-r--r--libs/ardour/playlist.cc1
-rw-r--r--libs/ardour/session_state.cc2
2 files changed, 3 insertions, 0 deletions
diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc
index 3508eaf0b3..2d89e9f44d 100644
--- a/libs/ardour/playlist.cc
+++ b/libs/ardour/playlist.cc
@@ -2409,6 +2409,7 @@ Playlist::state (bool full_state)
node->set_property ("combine-ops", _combine_ops);
for (RegionList::iterator i = regions.begin(); i != regions.end(); ++i) {
+ assert ((*i)->sources().size() > 0 && (*i)->master_sources().size() > 0);
node->add_child_nocopy ((*i)->get_state());
}
}
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc
index a7de032375..14da57e95c 100644
--- a/libs/ardour/session_state.cc
+++ b/libs/ardour/session_state.cc
@@ -1383,6 +1383,8 @@ Session::state (bool save_template, snapshot_t snapshot_type, bool only_used_ass
const RegionFactory::RegionMap& region_map (RegionFactory::all_regions());
for (RegionFactory::RegionMap::const_iterator i = region_map.begin(); i != region_map.end(); ++i) {
boost::shared_ptr<Region> r = i->second;
+ /* regions must have sources */
+ assert (r->sources().size() > 0 && r->master_sources().size() > 0);
/* only store regions not attached to playlists */
if (r->playlist() == 0) {
if (boost::dynamic_pointer_cast<AudioRegion>(r)) {