From fe2651ae5fd51620396bf26b82de18e1f5626e43 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 2 May 2011 23:22:00 +0000 Subject: Remove playlists from the session lists when they DropReferences. Should fix #4023. git-svn-id: svn://localhost/ardour2/branches/3.0@9460 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/session_playlists.h | 1 + libs/ardour/session_playlists.cc | 12 ++++++++++++ 2 files changed, 13 insertions(+) (limited to 'libs/ardour') diff --git a/libs/ardour/ardour/session_playlists.h b/libs/ardour/ardour/session_playlists.h index fe47d171ad..c6741ef319 100644 --- a/libs/ardour/ardour/session_playlists.h +++ b/libs/ardour/ardour/session_playlists.h @@ -64,6 +64,7 @@ private: bool add (boost::shared_ptr); void remove (boost::shared_ptr); + void remove_weak (boost::weak_ptr); void track (bool, boost::weak_ptr); uint32_t n_playlists() const; diff --git a/libs/ardour/session_playlists.cc b/libs/ardour/session_playlists.cc index 1e5a276ad4..b4f85aa1a0 100644 --- a/libs/ardour/session_playlists.cc +++ b/libs/ardour/session_playlists.cc @@ -78,11 +78,23 @@ SessionPlaylists::add (boost::shared_ptr playlist) if (!existing) { playlists.insert (playlists.begin(), playlist); playlist->InUse.connect_same_thread (*this, boost::bind (&SessionPlaylists::track, this, _1, boost::weak_ptr(playlist))); + playlist->DropReferences.connect_same_thread ( + *this, boost::bind (&SessionPlaylists::remove_weak, this, boost::weak_ptr (playlist)) + ); } return existing; } +void +SessionPlaylists::remove_weak (boost::weak_ptr playlist) +{ + boost::shared_ptr p = playlist.lock (); + if (p) { + remove (p); + } +} + void SessionPlaylists::remove (boost::shared_ptr playlist) { -- cgit v1.2.3