From 02115563feabd8d0019bfda605c88552c24f0890 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 2 Oct 2006 18:09:34 +0000 Subject: fixes for various bugs including dangling ref to route in session, opening sessions from the NSD, closing a session leaving dangling pointers etc etc git-svn-id: svn://localhost/ardour2/trunk@938 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/session.cc | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'libs/ardour/session.cc') diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 057774b49c..bf5f5fcb78 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -1825,7 +1825,10 @@ Session::add_routes (RouteList& new_routes, bool save) } for (RouteList::iterator x = new_routes.begin(); x != new_routes.end(); ++x) { - (*x)->solo_changed.connect (sigc::bind (mem_fun (*this, &Session::route_solo_changed), (*x))); + + boost::weak_ptr wpr (*x); + + (*x)->solo_changed.connect (sigc::bind (mem_fun (*this, &Session::route_solo_changed), wpr)); (*x)->mute_changed.connect (mem_fun (*this, &Session::route_mute_changed)); (*x)->output_changed.connect (mem_fun (*this, &Session::set_worst_io_latencies_x)); (*x)->redirects_changed.connect (mem_fun (*this, &Session::update_latency_compensation_proxy)); @@ -1883,11 +1886,11 @@ Session::remove_route (shared_ptr route) */ if (route == _master_out) { - _master_out = shared_ptr ((Route*) 0); + _master_out = shared_ptr (); } if (route == _control_out) { - _control_out = shared_ptr ((Route*) 0); + _control_out = shared_ptr (); /* cancel control outs for all routes */ @@ -1925,13 +1928,21 @@ Session::remove_route (shared_ptr route) update_latency_compensation (false, false); set_dirty(); - /* XXX should we disconnect from the Route's signals ? */ + /* get rid of it from the dead wood collection in the route list manager */ + + /* XXX i think this is unsafe as it currently stands, but i am not sure. (pd, october 2nd, 2006) */ - save_state (_current_snapshot_name); + routes.flush (); /* try to cause everyone to drop their references */ route->drop_references (); + + /* save the new state of the world */ + + if (save_state (_current_snapshot_name)) { + save_history (_current_snapshot_name); + } } void @@ -1941,7 +1952,7 @@ Session::route_mute_changed (void* src) } void -Session::route_solo_changed (void* src, shared_ptr route) +Session::route_solo_changed (void* src, boost::weak_ptr wpr) { if (solo_update_disabled) { // We know already @@ -1949,8 +1960,15 @@ Session::route_solo_changed (void* src, shared_ptr route) } bool is_track; - - is_track = (dynamic_cast(route.get()) != 0); + boost::shared_ptr route = wpr.lock (); + + if (!route) { + /* should not happen */ + error << string_compose (_("programming error: %1"), X_("invalid route weak ptr passed to route_solo_changed")) << endmsg; + return; + } + + is_track = (boost::dynamic_pointer_cast(route) != 0); shared_ptr r = routes.reader (); -- cgit v1.2.3