]> git.sesse.net Git - kdenlive/blobdiff - src/customtrackview.cpp
Fix timeline corruption when creating new project with fps != default fps
[kdenlive] / src / customtrackview.cpp
index 3865dd831c0cf1defa768f84103c381091b53a0f..b7cda93f09a83aed1f94e537cc4b39be3a801ebf 100644 (file)
@@ -373,6 +373,7 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
 {
     int pos = event->x();
     int mappedXPos = qMax((int)(mapToScene(event->pos()).x() + 0.5), 0);
+   
     double snappedPos = getSnapPointForPos(mappedXPos);
     emit mousePosition(mappedXPos);
 
@@ -925,7 +926,6 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event)
         } else resetSelectionGroup();
         dragGroup = NULL;
         if (m_dragItem->parentItem() && m_dragItem->parentItem()->type() == GROUPWIDGET) {
-            //kDebug()<<"// KLIK FOUND GRP: "<<m_dragItem->sceneBoundingRect();
             dragGroup = static_cast <AbstractGroupItem *>(m_dragItem->parentItem());
         }
         bool selected = !m_dragItem->isSelected();
@@ -1430,6 +1430,10 @@ bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint pos)
             kDebug() << " WARNING))))))))) CLIP NOT FOUND : " << list.at(0);
             return false;
         }
+        if (clip->producer() == NULL) {
+            emit displayMessage(i18n("Clip not ready"), ErrorMessage);
+            return false;
+        }
         QPointF framePos = mapToScene(pos);
         ItemInfo info;
         info.startPos = GenTime();
@@ -1481,6 +1485,10 @@ bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint pos)
                 kDebug() << " WARNING))))))))) CLIP NOT FOUND : " << ids.at(i);
                 return false;
             }
+            if (clip->producer() == NULL) {
+                emit displayMessage(i18n("Clip not ready"), ErrorMessage);
+                return false;
+            }
             ItemInfo info;
             info.startPos = start;
             info.cropDuration = clip->duration();
@@ -1813,8 +1821,11 @@ void CustomTrackView::slotDeleteEffect(ClipItem *clip, int track, QDomElement ef
                 }
             }
         }
-        if (delCommand->childCount() > 0) m_commandStack->push(delCommand);
-        else delete delCommand;
+        if (delCommand->childCount() > 0)
+            m_commandStack->push(delCommand);
+        else
+            delete delCommand;
+        setDocumentModified();
         return;
     }
     AddEffectCommand *command = new AddEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), effect, false);
@@ -2899,7 +2910,7 @@ void CustomTrackView::slotInsertSpace()
     track = d.selectedTrack();
 
     QList<QGraphicsItem *> items;
-    if (track > 0) {
+    if (track >= 0) {
         if (m_document->isTrackLocked(m_document->tracksCount() - track - 1)) {
             emit displayMessage(i18n("Cannot insert space in a locked track"), ErrorMessage);
             return;
@@ -3046,7 +3057,7 @@ void CustomTrackView::setCursorPos(int pos, bool seek)
     if (pos == m_cursorPos) return;
     emit cursorMoved((int)(m_cursorPos), (int)(pos));
     m_cursorPos = pos;
-    if (seek) m_document->renderer()->seek(GenTime(m_cursorPos, m_document->fps()));
+    if (seek) m_document->renderer()->seek(m_cursorPos);
     else if (m_autoScroll) checkScrolling();
     m_cursorLine->setPos(m_cursorPos, 0);
 }
@@ -3067,7 +3078,7 @@ void CustomTrackView::moveCursorPos(int delta)
     emit cursorMoved((int)(m_cursorPos), (int)((m_cursorPos + delta)));
     m_cursorPos += delta;
     m_cursorLine->setPos(m_cursorPos, 0);
-    m_document->renderer()->seek(GenTime(m_cursorPos, m_document->fps()));
+    m_document->renderer()->seek(m_cursorPos);
 }
 
 void CustomTrackView::initCursorPos(int pos)
@@ -3169,7 +3180,6 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
         resetSelectionGroup(false);
         m_operationMode = NONE;
     } else if (m_operationMode == RUBBERSELECTION) {
-        //kDebug() << "// END RUBBER SELECT";
         resetSelectionGroup();
         groupSelectedItems();
         m_operationMode = NONE;
@@ -4045,11 +4055,10 @@ void CustomTrackView::slotUpdateClip(const QString &clipId, bool reload)
             if (clip->clipProducer() == clipId) {
                 ItemInfo info = clip->info();
                 info.track = m_document->tracksCount() - clip->track();
-                if (reload && !m_document->renderer()->mltUpdateClip(info, clip->xml(), clip->baseClip()->producer())) {
+                if (reload && !m_document->renderer()->mltUpdateClip(info, clip->xml(), clip->baseClip()->producer(info.track))) {
                     emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", info.startPos.frames(m_document->fps()), info.track), ErrorMessage);
                 }
-                clip->refreshClip(true);
-                clip->update();
+                clip->refreshClip(true, true);
             }
         }
     }
@@ -4474,7 +4483,7 @@ void CustomTrackView::prepareResizeClipStart(AbstractClipItem* item, ItemInfo ol
             }
 
             /*
-                TODO: cleanup the effect update process
+             * TODO: cleanup the effect update process
              */
             ClipItem *clip = static_cast < ClipItem * >(item);
 
@@ -5591,7 +5600,7 @@ void CustomTrackView::slotUpdateAllThumbs()
                         item->slotSetEndThumb(pix);
                     }
                 }
-                item->refreshClip(false);
+                item->refreshClip(false, false);
             }
         }
     }
@@ -6610,4 +6619,16 @@ void CustomTrackView::updateTrackDuration(int track, QUndoCommand *command)
     }
 }
 
-
+void CustomTrackView::slotRefreshThumbs(const QString &id, bool resetThumbs)
+{
+    QList<QGraphicsItem *> list = scene()->items();
+    ClipItem *clip = NULL;
+    for (int i = 0; i < list.size(); ++i) {
+        if (list.at(i)->type() == AVWIDGET) {
+            clip = static_cast <ClipItem *>(list.at(i));
+            if (clip->clipProducer() == id) {
+                clip->refreshClip(true, resetThumbs);
+            }
+        }
+    }
+}