From fa41cfef580b2c8c04adec5b47d6cfa415ca6251 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 2 Mar 2011 11:30:37 +0000 Subject: [PATCH] Less subtle attempt to prevent crashes on removing sources during session deletion. git-svn-id: svn://localhost/ardour2/branches/3.0@9028 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/session.cc | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 63f5dc8e43..c554996a49 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -302,15 +302,9 @@ Session::destroy () routes.flush (); DEBUG_TRACE (DEBUG::Destruction, "delete sources\n"); - for (SourceMap::iterator i = sources.begin(); i != sources.end(); ) { - - SourceMap::iterator j = i; - ++j; - + for (SourceMap::iterator i = sources.begin(); i != sources.end(); ++i) { DEBUG_TRACE(DEBUG::Destruction, string_compose ("Dropping for source %1 ; pre-ref = %2\n", i->second->path(), i->second.use_count())); i->second->drop_references (); - - i = j; } sources.clear (); @@ -2697,6 +2691,10 @@ Session::add_source (boost::shared_ptr source) void Session::remove_source (boost::weak_ptr src) { + if (_state_of_the_state & Deletion) { + return; + } + SourceMap::iterator i; boost::shared_ptr source = src.lock(); @@ -2708,7 +2706,6 @@ Session::remove_source (boost::weak_ptr src) Glib::Mutex::Lock lm (source_lock); if ((i = sources.find (source->id())) != sources.end()) { - cerr << "Removing source " << source->name() << endl; sources.erase (i); } } -- 2.30.2