From 7c09916b055332ded9a05dca026d98794856b072 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 27 Nov 2009 17:29:27 +0000 Subject: [PATCH] switch Route::fed_by from shared_ptr to weak_ptr and thus begin to allow Route destructors to be called git-svn-id: svn://localhost/ardour2/branches/3.0@6189 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/route.h | 2 +- libs/ardour/audioengine.cc | 4 ++++ libs/ardour/session.cc | 26 ++++++++++++++++++-------- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index e3c3a370a9..6c6acb89bd 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -268,7 +268,7 @@ class Route : public SessionObject, public AutomatableControls void drop_listen (boost::shared_ptr); bool feeds (boost::shared_ptr, bool* via_send_only = 0); - std::set > fed_by; + std::set > fed_by; /* Controls (not all directly owned by the Route */ diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc index b7a37824c9..2e5aea9047 100644 --- a/libs/ardour/audioengine.cc +++ b/libs/ardour/audioengine.cc @@ -1115,6 +1115,10 @@ AudioEngine::remove_all_ports () ps->clear (); } + + /* clear dead wood list too */ + + ports.flush (); } static void diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 792029c9cd..67f41a906f 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -99,6 +99,7 @@ using namespace std; using namespace ARDOUR; using namespace PBD; using boost::shared_ptr; +using boost::weak_ptr; bool Session::_disable_all_loaded_plugins = false; @@ -378,6 +379,12 @@ Session::destroy () delete _silent_buffers; delete _mix_buffers; + /* clear out any pending dead wood from RCU managed objects */ + + routes.flush (); + diskstreams.flush (); + _bundles.flush (); + AudioDiskstream::free_working_buffers(); Route::SyncOrderKeys.clear(); @@ -493,9 +500,7 @@ Session::destroy () delete mmc; - for (vector::iterator x = debug_pointers.begin(); x != debug_pointers.end(); ++x) { - boost_debug_shared_ptr_show (cerr, *x); - } + boost_debug_list_ptrs (); } void @@ -1449,15 +1454,18 @@ trace_terminal (shared_ptr r1, shared_ptr rbase) /* make a copy of the existing list of routes that feed r1 */ - set > existing = r1->fed_by; + set > existing = r1->fed_by; /* for each route that feeds r1, recurse, marking it as feeding rbase as well. */ - for (set >::iterator i = existing.begin(); i != existing.end(); ++i) { - r2 =* i; - + for (set >::iterator i = existing.begin(); i != existing.end(); ++i) { + if (!(r2 = (*i).lock ())) { + /* (*i) went away, ignore it */ + continue; + } + /* r2 is a route that feeds r1 which somehow feeds base. mark base as being fed by r2 */ @@ -1468,7 +1476,7 @@ trace_terminal (shared_ptr r1, shared_ptr rbase) /* 2nd level feedback loop detection. if r1 feeds or is fed by r2, stop here. - */ + */ if ((r1->fed_by.find (r2) != r1->fed_by.end()) && (r2->fed_by.find (r1) != r2->fed_by.end())) { continue; @@ -1512,6 +1520,8 @@ Session::resort_routes_using (shared_ptr r) for (i = r->begin(); i != r->end(); ++i) { + cerr << "\n\n\n CLEAR FED BY for " << (*i)->name() << endl; + (*i)->fed_by.clear (); for (j = r->begin(); j != r->end(); ++j) {