remove reference to PluginState in VST code, for real this time
[ardour.git] / libs / ardour / audio_playlist.cc
index 00c3038d255042177f28dce7d90da8ab82ceeb3b..19609da2a4c6df4f70fc236d930b4f20e9fa3c81 100644 (file)
@@ -42,9 +42,9 @@ using namespace PBD;
 AudioPlaylist::AudioPlaylist (Session& session, const XMLNode& node, bool hidden)
        : Playlist (session, node, hidden)
 {
-       in_set_state = true;
+       in_set_state++;
        set_state (node);
-       in_set_state = false;
+       in_set_state--;
 
        if (!hidden) {
                PlaylistCreated (this); /* EMIT SIGNAL */
@@ -121,8 +121,15 @@ AudioPlaylist::~AudioPlaylist ()
 
        notify_callbacks ();
 
-       for (Crossfades::iterator x = _crossfades.begin(); x != _crossfades.end(); ++x) {
+       for (Crossfades::iterator x = _crossfades.begin(); x != _crossfades.end(); ) {
+               Crossfades::iterator tmp;
+
+               tmp = x;
+               ++tmp;
+
                delete *x;
+
+               x = tmp;
        }
 }
 
@@ -226,6 +233,10 @@ AudioPlaylist::remove_dependents (boost::shared_ptr<Region> region)
 {
        Crossfades::iterator i, tmp;
        boost::shared_ptr<AudioRegion> r = boost::dynamic_pointer_cast<AudioRegion> (region);
+
+       if (in_set_state) {
+               return;
+       }
        
        if (r == 0) {
                fatal << _("programming error: non-audio Region passed to remove_overlap in audio playlist")
@@ -419,7 +430,7 @@ AudioPlaylist::check_dependents (boost::shared_ptr<Region> r, bool norefresh)
                                        
                                } else {
 
-                                       xfade = new Crossfade (other, region, Config->get_xfade_model(), Config->get_crossfades_active());
+                                       xfade = new Crossfade (other, region, Config->get_xfade_model(), Config->get_xfades_active());
                                        add_crossfade (*xfade);
                                }
                        } 
@@ -488,6 +499,9 @@ AudioPlaylist::set_state (const XMLNode& node)
        XMLNodeList nlist;
        XMLNodeConstIterator niter;
 
+       in_set_state++;
+       freeze ();
+
        Playlist::set_state (node);
 
        nlist = node.children();
@@ -516,6 +530,9 @@ AudioPlaylist::set_state (const XMLNode& node)
                }
        }
 
+       thaw ();
+       in_set_state++;
+
        return 0;
 }