summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2020-02-25 15:32:17 +0100
committerRobin Gareus <robin@gareus.org>2020-02-25 16:17:00 +0100
commit53a6b3e28d0d95896689e3e2ccd5e86c22f43fef (patch)
tree0dd8ac5e9241a03da990e01d51947295de9d29df /libs
parent28c141d450a3aa6c4c519c2148b8c07dd37b7e68 (diff)
Fix cleanup, lock source-list, emit SourceRemoved
This fixes various cases where SessionHandleRef shared_ptr<> were kept when sources were removed.
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/session_state.cc22
1 files changed, 19 insertions, 3 deletions
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc
index 7d24830e69..0e0f5eb109 100644
--- a/libs/ardour/session_state.cc
+++ b/libs/ardour/session_state.cc
@@ -3375,7 +3375,7 @@ Session::cleanup_sources (CleanupReport& rep)
{
// FIXME: needs adaptation to midi
- vector<boost::shared_ptr<Source> > dead_sources;
+ SourceList dead_sources;
string audio_path;
string midi_path;
vector<string> candidates;
@@ -3391,6 +3391,8 @@ Session::cleanup_sources (CleanupReport& rep)
_state_of_the_state = StateOfTheState (_state_of_the_state | InCleanup);
+ Glib::Threads::Mutex::Lock ls (source_lock, Glib::Threads::NOT_LOCK);
+
/* this is mostly for windows which doesn't allow file
* renaming if the file is in use. But we don't special
* case it because we need to know if this causes
@@ -3418,6 +3420,7 @@ Session::cleanup_sources (CleanupReport& rep)
rep.paths.clear ();
rep.space = 0;
+ ls.acquire ();
for (SourceMap::iterator i = sources.begin(); i != sources.end(); ) {
SourceMap::iterator tmp;
@@ -3431,11 +3434,11 @@ Session::cleanup_sources (CleanupReport& rep)
if (!i->second->used() && (i->second->length(i->second->natural_position()) > 0)) {
dead_sources.push_back (i->second);
- i->second->drop_references ();
}
i = tmp;
}
+ ls.release ();
/* build a list of all the possible audio directories for the session */
@@ -3476,6 +3479,7 @@ Session::cleanup_sources (CleanupReport& rep)
/* add our current source list
*/
+ ls.acquire ();
for (SourceMap::iterator i = sources.begin(); i != sources.end(); ) {
boost::shared_ptr<FileSource> fs;
SourceMap::iterator tmp = i;
@@ -3523,12 +3527,21 @@ Session::cleanup_sources (CleanupReport& rep)
* reference to it.
*/
+ dead_sources.push_back (i->second);
sources.erase (i);
}
}
i = tmp;
}
+ ls.release ();
+
+ for (SourceList::iterator i = dead_sources.begin(); i != dead_sources.end(); ++i) {
+ /* The following triggers Region::source_deleted (), which
+ * causes regions to drop the given source */
+ (*i)->drop_references ();
+ SourceRemoved (*i); /* EMIT SIGNAL */
+ }
/* now check each candidate source to see if it exists in the list of
* sources_used_by_all_snapshots. If it doesn't, put it into "unused".
@@ -3661,7 +3674,10 @@ Session::cleanup_sources (CleanupReport& rep)
rep.space += statbuf.st_size;
}
- /* dump the history list */
+ /* drop last Source references */
+ dead_sources.clear ();
+
+ /* dump the history list, remove references */
_history.clear ();