]> git.sesse.net Git - kdenlive/blobdiff - src/clipitem.cpp
Check & update clip length in timeline when doing a "clip reload" from project tree...
[kdenlive] / src / clipitem.cpp
index 190343209baf75dba58a77d9bf366ef357fe71df..3c0ebdb8a8467c9251f8424954b4a857d1c38312 100644 (file)
@@ -402,9 +402,24 @@ void ClipItem::resetThumbs()
 }
 
 
-void ClipItem::refreshClip()
-{
-    m_maxDuration = m_clip->maxDuration();
+void ClipItem::refreshClip(bool checkDuration)
+{
+    if (checkDuration && (m_maxDuration != m_clip->maxDuration())) {
+        m_maxDuration = m_clip->maxDuration();
+        if (m_clipType != IMAGE && m_clipType != TEXT && m_clipType != COLOR) {
+            if (m_cropStart + m_cropDuration > m_maxDuration) {
+                // Clip duration changed, make sure to stay in correct range
+                if (m_cropStart > m_maxDuration) {
+                    m_cropStart = GenTime();
+                    m_cropDuration = qMin(m_cropDuration, m_maxDuration);
+                    updateRectGeometry();
+                } else {
+                    m_cropDuration = m_maxDuration;
+                    updateRectGeometry();
+                }
+            }
+        }
+    }
     if (m_clipType == COLOR) {
         QString colour = m_clip->getProperty("colour");
         colour = colour.replace(0, 2, "#");