From 04ddba2662bcac95f7dca733becc2d4bac6e5235 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Tue, 4 Sep 2012 21:32:09 +0200 Subject: [PATCH] Fix crash on clip cut introduced in recent coverity fix: http://kdenlive.org/mantis/view.php?id=2718 --- src/customtrackview.cpp | 8 +++++++- src/renderer.cpp | 30 +++++++++++++----------------- src/renderer.h | 2 +- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index 5fb7afc3..29bbc263 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -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; diff --git a/src/renderer.cpp b/src/renderer.cpp index 26d64fe5..a506e4ef 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -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" diff --git a/src/renderer.h b/src/renderer.h index 2c81c830..0bd82f92 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -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 trackClipStartList, QMap trackTransitionStartList, int track, const GenTime &duration, const GenTime &timeOffset); int mltGetSpaceLength(const GenTime &pos, int track, bool fromBlankStart); -- 2.39.2