]> git.sesse.net Git - kdenlive/commitdiff
Fix playlist corruption when resizing clip end in middle of a track
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 31 Jan 2009 22:25:03 +0000 (22:25 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 31 Jan 2009 22:25:03 +0000 (22:25 +0000)
svn path=/branches/KDE4/; revision=3017

src/renderer.cpp

index 29ab2f8e8dff0a124c393e811a84ca9d2168f49a..cae99b1c07aabe73257dd5c571a33c844fcd0a7e 100644 (file)
@@ -2089,21 +2089,25 @@ bool Render::mltResizeClipEnd(ItemInfo info, GenTime clipDuration) {
     int previousDuration = trackPlaylist.clip_length(clipIndex) - 1;
     int newDuration = (int) clipDuration.frames(m_fps) - 1;
     trackPlaylist.resize_clip(clipIndex, previousStart, newDuration + previousStart);
-    //trackPlaylist.consolidate_blanks(0);
+    trackPlaylist.consolidate_blanks(0);
     // skip to next clip
     clipIndex++;
     int diff = newDuration - previousDuration;
-    kDebug() << "////////  RESIZE CLIP: " << clipIndex << "( pos: " << info.startPos.frames(25) << "), DIFF: " << diff << ", CURRENT DUR: " << previousDuration << ", NEW DUR: " << newDuration;
+    kDebug() << "////////  RESIZE CLIP: " << clipIndex << "( pos: " << info.startPos.frames(25) << "), DIFF: " << diff << ", CURRENT DUR: " << previousDuration << ", NEW DUR: " << newDuration << ", IX: " << clipIndex << ", MAX: " << trackPlaylist.count();
     if (diff > 0) {
         // clip was made longer, trim next blank if there is one.
-        if (trackPlaylist.is_blank(clipIndex)) {
-            int blankStart = trackPlaylist.clip_start(clipIndex);
-            int blankDuration = trackPlaylist.clip_length(clipIndex) - 1;
-            if (diff - blankDuration == 1) {
-                trackPlaylist.remove(clipIndex);
-            } else trackPlaylist.resize_clip(clipIndex, blankStart, blankStart + blankDuration - diff);
-        } else {
-            kDebug() << "/// RESIZE ERROR, NXT CLIP IS NOT BLK: " << clipIndex;
+        if (clipIndex < trackPlaylist.count()) {
+            // If this is not the last clip in playlist
+            if (trackPlaylist.is_blank(clipIndex)) {
+                int blankStart = trackPlaylist.clip_start(clipIndex);
+                int blankDuration = trackPlaylist.clip_length(clipIndex) - 1;
+                if (diff > blankDuration) kDebug() << "// ERROR blank clip is not large enough to get back required space!!!";
+                if (diff - blankDuration == 1) {
+                    trackPlaylist.remove(clipIndex);
+                } else trackPlaylist.remove_region(blankStart, diff - 1);
+            } else {
+                kDebug() << "/// RESIZE ERROR, NXT CLIP IS NOT BLK: " << clipIndex;
+            }
         }
     } else trackPlaylist.insert_blank(clipIndex, 0 - diff - 1);