From 1d0991d273610014a1adce347d69d30bf93fd594 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Tue, 14 Jun 2011 05:54:15 +0000 Subject: [PATCH] Fix crash on track deletion: http://kdenlive.org/mantis/view.php?id=2168 svn path=/trunk/kdenlive/; revision=5714 --- CHANGELOG | 1 + src/customtrackview.cpp | 6 +++--- src/docclipbase.cpp | 15 +++++++++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5d093d49..5c4af1d1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ HEAD + * Fix crash when deleting a track and having an audio clip on last track (http://kdenlive.org/mantis/view.php?id=2168) * Check for duration mismatch in clip producers when opening a document (can cause corruption) * Automatically create backups of the project file; they can be restored in a recovery dialog. * Allow to manually edit video4linux capture profile. diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index 56bc2b74..90e1ac8d 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -2743,9 +2743,9 @@ void CustomTrackView::removeTrack(int ix) clip->updateItem(); ItemInfo clipinfo = clip->info(); // We add a move clip command so that we get the correct producer for new track number - if (clip->clipType() == AV || clip->clipType() == AUDIO) { + if (clip->clipType() == AV || clip->clipType() == AUDIO || clip->clipType() == PLAYLIST) { Mlt::Producer *prod = clip->getProducer(clipinfo.track); - if (!m_document->renderer()->mltUpdateClipProducer((int)(m_document->tracksCount() - clipinfo.track), clipinfo.startPos.frames(m_document->fps()), prod)) { + if (prod == NULL || !m_document->renderer()->mltUpdateClipProducer((int)(m_document->tracksCount() - clipinfo.track), clipinfo.startPos.frames(m_document->fps()), prod)) { emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", clipinfo.startPos.frames(m_document->fps()), clipinfo.track), ErrorMessage); } } @@ -5309,7 +5309,7 @@ bool CustomTrackView::canBePastedTo(ItemInfo info, int type) const // If we are in overwrite mode, always allow the move return true; } - int height; + int height = m_tracksHeight - 2; int offset = 0; if (type == TRANSITIONWIDGET) { height = Transition::itemHeight(); diff --git a/src/docclipbase.cpp b/src/docclipbase.cpp index a0c11e5c..bcbad4aa 100644 --- a/src/docclipbase.cpp +++ b/src/docclipbase.cpp @@ -536,6 +536,14 @@ Mlt::Producer *DocClipBase::audioProducer(int track) } } if (m_audioTrackProducers.at(track) == NULL) { + int i; + for (i = 0; i < m_audioTrackProducers.count(); i++) + if (m_audioTrackProducers.at(i) != NULL) break; + if (i < m_audioTrackProducers.count()) { + // Could not find a valid producer for that clip, check in + return m_audioTrackProducers.at(i); + } + Mlt::Producer *base = producer(); m_audioTrackProducers[track] = new Mlt::Producer(*(base->profile()), base->get("resource")); if (m_properties.contains("force_aspect_num") && m_properties.contains("force_aspect_den") && m_properties.contains("frame_size")) @@ -581,7 +589,7 @@ Mlt::Producer *DocClipBase::producer(int track) /*for (int i = 0; i < m_baseTrackProducers.count(); i++) { if (m_baseTrackProducers.at(i)) kDebug() << "// PROD: " << i << ", ID: " << m_baseTrackProducers.at(i)->get("id"); }*/ - if (track == -1 || (m_clipType != AUDIO && m_clipType != AV)) { + if (track == -1 || (m_clipType != AUDIO && m_clipType != AV && m_clipType != PLAYLIST)) { if (m_baseTrackProducers.count() == 0) return NULL; for (int i = 0; i < m_baseTrackProducers.count(); i++) { if (m_baseTrackProducers.at(i) != NULL) @@ -599,7 +607,10 @@ Mlt::Producer *DocClipBase::producer(int track) for (i = 0; i < m_baseTrackProducers.count(); i++) if (m_baseTrackProducers.at(i) != NULL) break; - if (i >= m_baseTrackProducers.count()) return NULL; + if (i >= m_baseTrackProducers.count()) { + // Could not find a valid producer for that clip, check in + return NULL; + } if (KIO::NetAccess::exists(KUrl(m_baseTrackProducers.at(i)->get("resource")), KIO::NetAccess::SourceSide, 0)) m_baseTrackProducers[track] = new Mlt::Producer(*m_baseTrackProducers.at(i)->profile(), m_baseTrackProducers.at(i)->get("resource")); -- 2.39.2