]> git.sesse.net Git - kdenlive/commitdiff
Fix crash on clip cut introduced in recent coverity fix:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 4 Sep 2012 19:32:09 +0000 (21:32 +0200)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 4 Sep 2012 19:32:09 +0000 (21:32 +0200)
http://kdenlive.org/mantis/view.php?id=2718

src/customtrackview.cpp
src/renderer.cpp
src/renderer.h

index 5fb7afc3cdefae064fa9813d8f78d0c0199cb16c..29bbc263f7e7047b724c5454c694abf4bcef0984 100644 (file)
@@ -2204,7 +2204,13 @@ ClipItem *CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut, boo
             return NULL;
         }
 
-        if (execute) m_document->renderer()->mltCutClip(m_document->tracksCount() - info.track, cutTime);
+        if (execute) {
+           if (!m_document->renderer()->mltCutClip(m_document->tracksCount() - info.track, cutTime)) {
+               // Error cuting clip in playlist
+               m_blockRefresh = false;
+               return NULL;
+           }
+       }
         int cutPos = (int) cutTime.frames(m_document->fps());
         ItemInfo newPos;
         newPos.startPos = cutTime;
index 26d64fe5ecfe6dce3e1b6451f0d67afbe77f17d4..a506e4ef39cb815d950f7dcbfbe523823508a9d9 100644 (file)
@@ -1886,12 +1886,12 @@ int Render::mltInsertClip(ItemInfo info, QDomElement element, Mlt::Producer *pro
 }
 
 
-void Render::mltCutClip(int track, GenTime position)
+bool Render::mltCutClip(int track, GenTime position)
 {
     Mlt::Service service(m_mltProducer->parent().get_service());
     if (service.type() != tractor_type) {
         kWarning() << "// TRACTOR PROBLEM";
-        return;
+        return false;
     }
 
     Mlt::Tractor tractor(service);
@@ -1914,7 +1914,7 @@ void Render::mltCutClip(int track, GenTime position)
     int clipIndex = trackPlaylist.get_clip_index_at(cutPos);
     if (trackPlaylist.is_blank(clipIndex)) {
         kDebug() << "// WARNING, TRYING TO CUT A BLANK";
-        return;
+        return false;
     }
     service.lock();
     int clipStart = trackPlaylist.clip_start(clipIndex);
@@ -1924,21 +1924,15 @@ void Render::mltCutClip(int track, GenTime position)
     // duplicate effects
     Mlt::Producer *original = trackPlaylist.get_clip_at(clipStart);
     Mlt::Producer *clip = trackPlaylist.get_clip_at(cutPos);
+    
+    if (original == NULL || clip == NULL) {
+        kDebug() << "// ERROR GRABBING CLIP AFTER SPLIT";
+       return false;
+    }
 
-    Mlt::Service clipService;
-    Mlt::Service dupService;
-    if (original)
-        clipService = Mlt::Service(original->get_service());
-    else
-        clipService = Mlt::Service();
-
-    if (clip)
-        dupService = Mlt::Service(clip->get_service());
-    else
-        dupService = Mlt::Service();
+    Mlt::Service clipService(original->get_service());
+    Mlt::Service dupService(clip->get_service());
 
-    if (original == NULL || clip == NULL)
-        kDebug() << "// ERROR GRABBING CLIP AFTER SPLIT";
 
     delete original;
     delete clip;
@@ -1961,7 +1955,7 @@ void Render::mltCutClip(int track, GenTime position)
         ct++;
         filter = clipService.filter(ct);
     }
-
+    return true;
     /* // Display playlist info
     kDebug()<<"////////////  AFTER";
     for (int i = 0; i < trackPlaylist.count(); i++) {
@@ -4469,5 +4463,7 @@ bool Render::getBlackMagicOutputDeviceList(KComboBox *devicelist)
     return true;
 }
 
+
+
 #include "renderer.moc"
 
index 2c81c8307bf760d4a0ea5209ed4994c732adb63c..0bd82f92462a1f15ee65a35a899538a50838ccc6 100644 (file)
@@ -206,7 +206,7 @@ Q_OBJECT public:
     Mlt::Producer *checkSlowMotionProducer(Mlt::Producer *prod, QDomElement element);
     int mltInsertClip(ItemInfo info, QDomElement element, Mlt::Producer *prod, bool overwrite = false, bool push = false);
     bool mltUpdateClip(Mlt::Tractor *tractor, ItemInfo info, QDomElement element, Mlt::Producer *prod);
-    void mltCutClip(int track, GenTime position);
+    bool mltCutClip(int track, GenTime position);
     void mltInsertSpace(QMap <int, int> trackClipStartList, QMap <int, int> trackTransitionStartList, int track, const GenTime &duration, const GenTime &timeOffset);
     int mltGetSpaceLength(const GenTime &pos, int track, bool fromBlankStart);