Fix crash due to invalidated shared_ptr, as suggested by Paul
authorCarl Hetherington <carl@carlh.net>
Tue, 23 Oct 2007 12:50:25 +0000 (12:50 +0000)
committerCarl Hetherington <carl@carlh.net>
Tue, 23 Oct 2007 12:50:25 +0000 (12:50 +0000)
git-svn-id: svn://localhost/ardour2/trunk@2565 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/audio_playlist.cc

index d5c6120946f3daffb873e3cced312bd3a0ad82ed..f4c10cbc1295aedbf423418403407767e5bc007c 100644 (file)
@@ -271,11 +271,12 @@ AudioPlaylist::refresh_dependents (boost::shared_ptr<Region> r)
 
                if ((*x)->involves (ar)) {
 
-                       if (find (updated.begin(), updated.end(), *x) == updated.end()) {
-                               try { 
-                                       if ((*x)->refresh ()) {
-                                               updated.insert (*x);
-                                       }
+                       pair<set<boost::shared_ptr<Crossfade> >::iterator, bool> const u = updated.insert (*x);
+                       
+                       if (u.second) {
+                               /* x was successfully inserted into the set, so it has not already been updated */
+                               try {
+                                       (*x)->refresh ();
                                }
 
                                catch (Crossfade::NoCrossfadeHere& err) {