]> git.sesse.net Git - kdenlive/commitdiff
Fix crash when dragging keyframe ouside clip on left / right border:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 28 Jun 2010 08:30:33 +0000 (08:30 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 28 Jun 2010 08:30:33 +0000 (08:30 +0000)
http://www.kdenlive.org/mantis/view.php?id=1663

svn path=/trunk/kdenlive/; revision=4546

src/abstractclipitem.cpp
src/customtrackview.cpp

index cf9c60c328043f70642463c8d3553094fe5122a8..8ddc3859a41237ed712407fe9b6b64b0d63355d9 100644 (file)
@@ -131,14 +131,13 @@ void AbstractClipItem::resizeStart(int posx, bool hasSizeLimit)
     if (durationDiff == GenTime()) return;
     //kDebug() << "-- RESCALE DIFF=" << durationDiff.frames(25) << ", CLIP: " << startPos().frames(25) << "-" << endPos().frames(25);
 
-    if (type() == AVWIDGET && hasSizeLimit && cropStart() + durationDiff < GenTime()) {
-            durationDiff = GenTime() - cropStart();
+    if (type() == AVWIDGET && hasSizeLimit && (cropStart() + durationDiff < GenTime())) {
+        durationDiff = GenTime() - cropStart();
     } else if (durationDiff >= cropDuration()) {
         return;
         if (cropDuration() > GenTime(3, m_fps)) durationDiff = GenTime(3, m_fps);
         else return;
     }
-    //kDebug()<<"// DURATION DIFF: "<<durationDiff.frames(25)<<", POS: "<<pos().x();
     m_info.startPos += durationDiff;
 
     if (type() == AVWIDGET)
@@ -149,7 +148,7 @@ void AbstractClipItem::resizeStart(int posx, bool hasSizeLimit)
     moveBy(durationDiff.frames(m_fps), 0);
 
     if (m_info.startPos != GenTime(posx, m_fps)) {
-        //kDebug()<<"//////  WARNING, DIFF IN XPOS: "<<pos().x()<<" == "<<m_startPos.frames(m_fps);
+        //kDebug() << "//////  WARNING, DIFF IN XPOS: " << pos().x() << " == " << m_info.startPos.frames(m_fps);
         GenTime diff = m_info.startPos - GenTime(posx, m_fps);
 
         if (type() == AVWIDGET)
@@ -360,6 +359,8 @@ void AbstractClipItem::updateKeyFramePos(const GenTime pos, const double value)
     int newpos = (int) pos.frames(m_fps);
     int start = cropStart().frames(m_fps);
     int end = (cropStart() + cropDuration()).frames(m_fps) - 1;
+    if (editedKeyFramePos() > start && newpos <= start) newpos = start + 1;
+    if (editedKeyFramePos() < end && newpos >= end) newpos = end - 1;
     newpos = qMax(newpos, start);
     newpos = qMin(newpos, end);
 
index 7046d9787aff457e9e5e49a2cfa4c648cf4b2c26..eab1a6fd136c57c4298caed41934d02bc4e13622 100644 (file)
@@ -3270,11 +3270,12 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
         val = (br.bottom() - val) * maxh;
         int start = item->cropStart().frames(m_document->fps());
         int end = (item->cropStart() + item->cropDuration()).frames(m_document->fps()) - 1;
+
         if ((val < -50 || val > 150) && item->editedKeyFramePos() != start && item->editedKeyFramePos() != end) {
             //delete keyframe
-            kDebug() << "// DELETE KFR: " << item->editedKeyFramePos();
             item->movedKeyframe(item->getEffectAt(item->selectedEffectIndex()), item->selectedKeyFramePos(), -1, 0);
         } else item->movedKeyframe(item->getEffectAt(item->selectedEffectIndex()), item->selectedKeyFramePos(), item->editedKeyFramePos(), item->editedKeyFrameValue());
+
         QDomElement newEffect = item->selectedEffect().cloneNode().toElement();
         //item->updateKeyframeEffect();
         //QString next = item->keyframes(item->selectedEffectIndex());
@@ -4288,10 +4289,10 @@ void CustomTrackView::updatePositionEffects(ClipItem * item, ItemInfo info)
         QDomElement oldeffect = item->effectAt(effectPos);
         int start = item->cropStart().frames(m_document->fps());
         int max = start + item->cropDuration().frames(m_document->fps());
-       if (start < 0) {
-           max -= start;
-           start = 0;
-       }
+        if (start < 0) {
+            max -= start;
+            start = 0;
+        }
         oldeffect.setAttribute("in", start);
         oldeffect.setAttribute("out", max);
         if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), item->getEffectArgs(oldeffect)))