]> git.sesse.net Git - kdenlive/commitdiff
Fix crash on track deletion:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 14 Jun 2011 05:54:15 +0000 (05:54 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Tue, 14 Jun 2011 05:54:15 +0000 (05:54 +0000)
http://kdenlive.org/mantis/view.php?id=2168

svn path=/trunk/kdenlive/; revision=5714

CHANGELOG
src/customtrackview.cpp
src/docclipbase.cpp

index 5d093d497d3549cbe1ebf8939d1e08bbeb84c274..5c4af1d1536b74ff06e06003bdd767241e67c184 100644 (file)
--- 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.
index 56bc2b743d412eb7f315123b913514d55d960147..90e1ac8d0884debc86da0beabee15178fc3cd871 100644 (file)
@@ -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();
index a0c11e5c2df2bf9c48bf5770b6e1faccf92c933b..bcbad4aa98798224a806082c75d13eac072f36e8 100644 (file)
@@ -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"));