13
0

Fix incorrectly saved un-used playlists

This addresses issues with session-cleanup and region-cleanup in
some sessions.

The root-cause why some unused playlists were saved in the session XML
under <Playlists> and not <UnusedPlaylists> is not known.

Early 6.0-pre did incorrect reference counting, but also older sessions
had this issue. Perhaps due to ambiguities of matching playlists
by name in 5.x or session-format changes 3.x .. 5.x.
This commit is contained in:
Robin Gareus 2019-03-19 21:56:13 +01:00
parent c2e0fe8b3f
commit 50604d83de
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 28 additions and 0 deletions

View File

@ -72,6 +72,7 @@ private:
void remove (boost::shared_ptr<Playlist>);
void remove_weak (boost::weak_ptr<Playlist>);
void track (bool, boost::weak_ptr<Playlist>);
void update_tracking ();
void find_equivalent_playlist_regions (boost::shared_ptr<Region>, std::vector<boost::shared_ptr<Region> >& result);
void update_after_tempo_map_change ();

View File

@ -111,6 +111,30 @@ SessionPlaylists::remove (boost::shared_ptr<Playlist> playlist)
}
}
void
SessionPlaylists::update_tracking ()
{
/* This is intended to be called during session-load, after loading
* playlists and re-assigning them to tracks (refcnt is up to date).
* Check playlist refcnt, move unused playlist to unused_playlists
* array (which may be the case when loading old sessions)
*/
for (List::iterator i = playlists.begin(); i != playlists.end(); ) {
if ((*i)->hidden () || (*i)->used ()) {
++i;
continue;
}
warning << _("Session State: Unused playlist was listed as used.") << endmsg;
assert (unused_playlists.find (*i) == unused_playlists.end());
unused_playlists.insert (*i);
List::iterator rm = i;
++i;
playlists.erase (rm);
}
}
void
SessionPlaylists::track (bool inuse, boost::weak_ptr<Playlist> wpl)

View File

@ -1702,6 +1702,9 @@ Session::set_state (const XMLNode& node, int version)
goto out;
}
/* Now that we Tracks have been loaded and playlists are assigned */
_playlists->update_tracking ();
/* Now that we have Routes and masters loaded, connect them if appropriate */
Slavable::Assign (_vca_manager); /* EMIT SIGNAL */