Fix an assertion failure when stopping the transport with an active controllable...
authorCarl Hetherington <carl@carlh.net>
Wed, 20 Apr 2011 01:24:46 +0000 (01:24 +0000)
committerCarl Hetherington <carl@carlh.net>
Wed, 20 Apr 2011 01:24:46 +0000 (01:24 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@9389 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/automatable.cc
libs/ardour/automation_list.cc

index 100e7ddb3cc89ae7e0feb4b314791a831dbea6af..392938fde2fa9ee527ddf1905f795fd811976287 100644 (file)
@@ -417,6 +417,13 @@ Automatable::transport_stopped (framepos_t now)
                                = boost::dynamic_pointer_cast<AutomationList>(c->list());
                         
                         if (l) {
+                               /* Stop any active touch gesture just before we mark the write pass
+                                  as finished.  If we don't do this, the transport can end up stopped with
+                                  an AutomationList thinking that a touch is still in progress and,
+                                  when the transport is re-started, a touch will magically
+                                  be happening without it ever have being started in the usual way.
+                               */
+                               l->stop_touch (true, now);
                                 l->write_pass_finished (now);
                                 
                                 if (l->automation_playback()) {
index b76fa0bb4bc6e2108b98f931de8aafa39493c4ed..aaab84f2da7b50d07163d303f042e36f7631b8fa 100644 (file)
@@ -213,21 +213,30 @@ AutomationList::start_touch (double when)
 void
 AutomationList::stop_touch (bool mark, double when)
 {
+       if (g_atomic_int_get (&_touching) == 0) {
+               /* this touch has already been stopped (probably by Automatable::transport_stopped),
+                  so we've nothing to do.
+               */
+               return;
+       }
+       
        g_atomic_int_set (&_touching, 0);
 
         if (_state == Touch) {
+
+               assert (!nascent.empty ());
+
                 Glib::Mutex::Lock lm (ControlList::_lock);
                 
                 if (mark) {
-                        nascent.back()->end_time = when;
+
+                       nascent.back()->end_time = when;
                         
                 } else {
                         
                         /* nascent info created in start touch but never used. just get rid of it.
                          */
 
-                       assert (!nascent.empty ());
-                        
                         NascentInfo* ninfo = nascent.back ();
                         nascent.erase (nascent.begin());
                         delete ninfo;