stop deadlock when pasting into a playlist
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 23 May 2012 20:32:12 +0000 (20:32 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 23 May 2012 20:32:12 +0000 (20:32 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@12400 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/playlist.cc

index 0e1aad110db35a3d707cede4a898cd681adfe051..12490d02d7b7d4a9ce5da12a9ef882b1c9e5db5b 100644 (file)
@@ -1196,7 +1196,6 @@ Playlist::flush_notifications (bool from_undo)
         times = fabs (times);
 
         {
-                RegionWriteLock rl1 (this);
                 RegionReadLock rl2 (other.get());
 
                 int itimes = (int) floor (times);
@@ -1204,18 +1203,21 @@ Playlist::flush_notifications (bool from_undo)
                 framecnt_t const shift = other->_get_extent().second;
                 layer_t top = top_layer ();
 
-                while (itimes--) {
-                        for (RegionList::iterator i = other->regions.begin(); i != other->regions.end(); ++i) {
-                                boost::shared_ptr<Region> copy_of_region = RegionFactory::create (*i, true);
-
-                                /* put these new regions on top of all existing ones, but preserve
-                                   the ordering they had in the original playlist.
-                                */
-
-                                add_region_internal (copy_of_region, (*i)->position() + pos);
-                                set_layer (copy_of_region, copy_of_region->layer() + top);
+                {
+                        RegionWriteLock rl1 (this);
+                        while (itimes--) {
+                                for (RegionList::iterator i = other->regions.begin(); i != other->regions.end(); ++i) {
+                                        boost::shared_ptr<Region> copy_of_region = RegionFactory::create (*i, true);
+                                        
+                                        /* put these new regions on top of all existing ones, but preserve
+                                           the ordering they had in the original playlist.
+                                        */
+                                        
+                                        add_region_internal (copy_of_region, (*i)->position() + pos);
+                                        set_layer (copy_of_region, copy_of_region->layer() + top);
+                                }
+                                pos += shift;
                         }
-                        pos += shift;
                 }
         }