Remove playlists from the session lists when they DropReferences. Should fix #4023.
authorCarl Hetherington <carl@carlh.net>
Mon, 2 May 2011 23:22:00 +0000 (23:22 +0000)
committerCarl Hetherington <carl@carlh.net>
Mon, 2 May 2011 23:22:00 +0000 (23:22 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@9460 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ardour/session_playlists.h
libs/ardour/session_playlists.cc

index fe47d171ad7a5641d6aa9eb17856871e9ce2d23e..c6741ef319d761ca832b2da0a211b8cb98b0ac6b 100644 (file)
@@ -64,6 +64,7 @@ private:
        
        bool add (boost::shared_ptr<Playlist>);
        void remove (boost::shared_ptr<Playlist>);
+       void remove_weak (boost::weak_ptr<Playlist>);
        void track (bool, boost::weak_ptr<Playlist>);
        
        uint32_t n_playlists() const;
index 1e5a276ad4a2afc67ddbbd5e21fbcb4b2771b641..b4f85aa1a03cd71110fd5089266f6e0ec410cbe2 100644 (file)
@@ -78,11 +78,23 @@ SessionPlaylists::add (boost::shared_ptr<Playlist> 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)));
+               playlist->DropReferences.connect_same_thread (
+                       *this, boost::bind (&SessionPlaylists::remove_weak, this, boost::weak_ptr<Playlist> (playlist))
+                       );
        }
 
        return existing;
 }
 
+void
+SessionPlaylists::remove_weak (boost::weak_ptr<Playlist> playlist)
+{
+       boost::shared_ptr<Playlist> p = playlist.lock ();
+       if (p) {
+               remove (p);
+       }
+}
+
 void
 SessionPlaylists::remove (boost::shared_ptr<Playlist> playlist)
 {