From: Jean-Baptiste Mardelle Date: Sat, 31 Jan 2009 22:25:03 +0000 (+0000) Subject: Fix playlist corruption when resizing clip end in middle of a track X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=3644bf4707c77542bc0900ce3c4dbbe674b08a07;p=kdenlive Fix playlist corruption when resizing clip end in middle of a track svn path=/branches/KDE4/; revision=3017 --- diff --git a/src/renderer.cpp b/src/renderer.cpp index 29ab2f8e..cae99b1c 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -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);