When a region movement is undone, prevent the resulting movement from triggering...
authorCarl Hetherington <carl@carlh.net>
Thu, 22 Jul 2010 01:22:33 +0000 (01:22 +0000)
committerCarl Hetherington <carl@carlh.net>
Thu, 22 Jul 2010 01:22:33 +0000 (01:22 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@7464 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ardour/audioplaylist.h
libs/ardour/ardour/diskstream.h
libs/ardour/ardour/playlist.h
libs/ardour/audio_playlist.cc
libs/ardour/diskstream.cc
libs/ardour/playlist.cc

index b53f3c1f7317d0578336913df0a6af169f287d95..aee5fb3f649f30ed1007a12824b115505e5abdbf 100644 (file)
@@ -63,7 +63,7 @@ class AudioPlaylist : public ARDOUR::Playlist
 
        /* playlist "callbacks" */
        void notify_crossfade_added (boost::shared_ptr<Crossfade>);
-       void flush_notifications ();
+       void flush_notifications (bool);
 
        void finalize_split_region (boost::shared_ptr<Region> orig, boost::shared_ptr<Region> left, boost::shared_ptr<Region> right);
 
index d0d2bcbc365f5c48c03960d68c1f6638c4195fc0..716cc13063f99caffdaf752c1a095cb724785a68 100644 (file)
@@ -208,7 +208,7 @@ class Diskstream : public SessionObject, public PublicDiskstream
 
        virtual void playlist_changed (const PBD::PropertyChange&);
        virtual void playlist_deleted (boost::weak_ptr<Playlist>);
-       virtual void playlist_ranges_moved (std::list< Evoral::RangeMove<framepos_t> > const &);
+       virtual void playlist_ranges_moved (std::list< Evoral::RangeMove<framepos_t> > const &, bool);
 
        virtual void transport_stopped_wallclock (struct tm&, time_t, bool abort) = 0;
        virtual void transport_looped (nframes_t transport_frame) = 0;
index 7afc074b4def9f7e47c953a51f936127d6cda552..100a0f771303ad5015f6e5644fa71bd005fc611b 100644 (file)
@@ -182,12 +182,12 @@ class Playlist : public SessionObject
        PBD::Signal0<void>      NameChanged;
        PBD::Signal0<void>      LengthChanged;
        PBD::Signal0<void>      LayeringChanged;
-       PBD::Signal1<void,std::list< Evoral::RangeMove<framepos_t> > const &> RangesMoved;
+       PBD::Signal2<void,std::list< Evoral::RangeMove<framepos_t> > const &, bool> RangesMoved;
 
        static std::string bump_name (std::string old_name, Session&);
 
        void freeze ();
-       void thaw ();
+       void thaw (bool from_undo = false);
 
        void raise_region (boost::shared_ptr<Region>);
        void lower_region (boost::shared_ptr<Region>);
@@ -289,8 +289,8 @@ class Playlist : public SessionObject
        }
 
        void delay_notifications ();
-       void release_notifications ();
-       virtual void flush_notifications ();
+       void release_notifications (bool from_undo = false);
+       virtual void flush_notifications (bool from_undo = false);
        void clear_pending ();
 
         void _set_sort_id ();
index cb65164a9b03f2adb4be7032798227d72948e8fe..30e52fa316bdbaa804db1aeaf25eed74bfeb720d 100644 (file)
@@ -241,9 +241,9 @@ AudioPlaylist::remove_dependents (boost::shared_ptr<Region> region)
 
 
 void
-AudioPlaylist::flush_notifications ()
+AudioPlaylist::flush_notifications (bool from_undo)
 {
-       Playlist::flush_notifications();
+       Playlist::flush_notifications (from_undo);
 
        if (in_flush) {
                return;
index 5dd9a3b3061dd0d025ba54da82a1220dc0b76dcd..064049049b7871a28269480d3dbe56a74fb744d2 100644 (file)
@@ -363,7 +363,7 @@ Diskstream::use_playlist (boost::shared_ptr<Playlist> playlist)
 
                _playlist->ContentsChanged.connect_same_thread (playlist_connections, boost::bind (&Diskstream::playlist_modified, this));
                _playlist->DropReferences.connect_same_thread (playlist_connections, boost::bind (&Diskstream::playlist_deleted, this, boost::weak_ptr<Playlist>(_playlist)));
-               _playlist->RangesMoved.connect_same_thread (playlist_connections, boost::bind (&Diskstream::playlist_ranges_moved, this, _1));
+               _playlist->RangesMoved.connect_same_thread (playlist_connections, boost::bind (&Diskstream::playlist_ranges_moved, this, _1, _2));
        }
 
        /* don't do this if we've already asked for it *or* if we are setting up
@@ -436,8 +436,17 @@ Diskstream::set_name (const string& str)
 }
 
 void
-Diskstream::playlist_ranges_moved (list< Evoral::RangeMove<framepos_t> > const & movements_frames)
+Diskstream::playlist_ranges_moved (list< Evoral::RangeMove<framepos_t> > const & movements_frames, bool from_undo)
 {
+       /* If we're coming from an undo, it will have handled
+          automation undo (it must, since automation-follows-regions
+          can lose automation data).  Hence we can do nothing here.
+       */
+       
+       if (from_undo) {
+               return;
+       }
+       
        if (!_track || Config->get_automation_follows_regions () == false) {
                return;
        }
@@ -483,7 +492,10 @@ Diskstream::move_processor_automation (boost::weak_ptr<Processor> p, list< Evora
 
        set<Evoral::Parameter> const a = processor->what_can_be_automated ();
 
+       cout << "move processor auto for " << processor->name() << "\n";
+
        for (set<Evoral::Parameter>::iterator i = a.begin (); i != a.end (); ++i) {
+               cout << "moving " << *i << "\n";
                boost::shared_ptr<AutomationList> al = processor->automation_control(*i)->alist();
                XMLNode & before = al->get_state ();
                al->move_ranges (movements);
index 525749181530b18556b1f23400233cb70bb74e98..4c9b8f4bf2a45d09019b5475312095190e658b47 100644 (file)
@@ -446,7 +446,7 @@ Playlist::begin_undo ()
 void
 Playlist::end_undo ()
 {
-       thaw ();
+       thaw (true);
         in_update = false;
 }
 
@@ -457,11 +457,12 @@ Playlist::freeze ()
        g_atomic_int_inc (&ignore_state_changes);
 }
 
+/** @param from_undo true if this thaw is triggered by the end of an undo on this playlist */
 void
-Playlist::thaw ()
+Playlist::thaw (bool from_undo)
 {
        g_atomic_int_dec_and_test (&ignore_state_changes);
-       release_notifications ();
+       release_notifications (from_undo);
 }
 
 
@@ -472,11 +473,12 @@ Playlist::delay_notifications ()
        freeze_length = _get_extent().second;
 }
 
+/** @param from_undo true if this release is triggered by the end of an undo on this playlist */
 void
-Playlist::release_notifications ()
+Playlist::release_notifications (bool from_undo)
 {
        if (g_atomic_int_dec_and_test (&block_notifications)) {
-               flush_notifications ();
+               flush_notifications (from_undo);
         }
 
 }
@@ -535,7 +537,7 @@ Playlist::notify_region_moved (boost::shared_ptr<Region> r)
 
                list< Evoral::RangeMove<framepos_t> > m;
                m.push_back (move);
-               RangesMoved (m);
+               RangesMoved (m, false);
        }
 
 }
@@ -574,8 +576,9 @@ Playlist::notify_length_changed ()
        }
 }
 
+/** @param from_undo true if this flush is triggered by the end of an undo on this playlist */
 void
-Playlist::flush_notifications ()
+Playlist::flush_notifications (bool from_undo)
 {
        set<boost::shared_ptr<Region> > dependent_checks_needed;
        set<boost::shared_ptr<Region> >::iterator s;
@@ -661,8 +664,7 @@ Playlist::flush_notifications ()
        }
 
        if (!pending_range_moves.empty ()) {
-               // cerr << _name << " sends RangesMoved\n";
-               RangesMoved (pending_range_moves);
+               RangesMoved (pending_range_moves, from_undo);
        }
        
        clear_pending ();