]> git.sesse.net Git - kdenlive/commitdiff
Fix crash with placeholder clips:
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Thu, 9 Apr 2009 17:34:41 +0000 (17:34 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Thu, 9 Apr 2009 17:34:41 +0000 (17:34 +0000)
http://www.kdenlive.org/mantis/view.php?id=755

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

src/customtrackview.cpp
src/docclipbase.cpp
src/projectlistview.cpp
src/renderer.cpp

index 2bdb7f512c1af4217fb39ff7097b34ec0f6bc0fc..f41298b48f59634b47de21b5035a1a2b3c8cac0c 100644 (file)
@@ -1659,7 +1659,7 @@ void CustomTrackView::dropEvent(QDropEvent * event)
             m_document->renderer()->mltInsertClip(info, item->xml(), item->baseClip()->producer(item->track()));
             item->setSelected(true);
         }
-       m_document->setModified(true);
+        m_document->setModified(true);
         m_changeSpeedAction->setEnabled(hasVideoClip);
         m_pasteEffectsAction->setEnabled(m_copiedItems.count() == 1);
         groupSelectedItems(true);
@@ -2281,8 +2281,10 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
                     m_commandStack->push(moveCommand);
                 } else {
                     // undo last move and emit error message
-                    MoveClipCommand *command = new MoveClipCommand(this, info, m_dragItemInfo, true);
-                    m_commandStack->push(command);
+                    bool snap = KdenliveSettings::snaptopoints();
+                    KdenliveSettings::setSnaptopoints(false);
+                    item->setPos((int) m_dragItemInfo.startPos.frames(m_document->fps()), (int)(m_dragItemInfo.track * m_tracksHeight + 1));
+                    KdenliveSettings::setSnaptopoints(snap);
                     emit displayMessage(i18n("Cannot move clip to position %1", m_document->timecode().getTimecodeFromFrames(m_dragItemInfo.startPos.frames(m_document->fps()))), ErrorMessage);
                 }
                 m_document->setModified(true);
index b11ba095ffcbacbc3fb09e0cad04bc6f979dd16a..882858f1f01465ed67d5d3c991ed41dd3f19a936 100644 (file)
@@ -516,8 +516,13 @@ Mlt::Producer *DocClipBase::producer(int track)
         int i;
         for (i = 0; i < m_baseTrackProducers.count(); i++)
             if (m_baseTrackProducers.at(i) != NULL) break;
+
         if (i >= m_baseTrackProducers.count()) return NULL;
         m_baseTrackProducers[track] = new Mlt::Producer(*m_baseTrackProducers.at(i)->profile(), m_baseTrackProducers.at(i)->get("resource"));
+
+       // special case for placeholder clips
+       if (m_baseTrackProducers[track] == NULL) return NULL;
+
         if (m_properties.contains("force_aspect_ratio")) m_baseTrackProducers[track]->set("force_aspect_ratio", m_properties.value("force_aspect_ratio").toDouble());
         if (m_properties.contains("threads")) m_baseTrackProducers[track]->set("threads", m_properties.value("threads").toInt());
         if (m_properties.contains("video_index")) m_baseTrackProducers[track]->set("video_index", m_properties.value("video_index").toInt());
index b050630580c7197e11f0153e1d4c43381096a28a..8b0182021b74fbf7c284db087bc891e51d3db789 100644 (file)
@@ -116,8 +116,8 @@ void ProjectListView::mouseDoubleClickEvent(QMouseEvent * event)
 {
     ProjectItem *item = static_cast <ProjectItem *>(itemAt(event->pos()));
     if (!item) {
-       emit addClip();
-       return;
+        emit addClip();
+        return;
     }
     if (!(item->flags() & Qt::ItemIsDragEnabled)) return;
     if (item->isGroup()) {
index 62681c1f55ee5041e02b6061e3b183425916976b..89144b022ce65669507a8e98550431036a3105ce 100644 (file)
@@ -2388,10 +2388,10 @@ bool Render::mltMoveClip(int startTrack, int endTrack, int moveStart, int moveEn
     kDebug() << "//////  LOOKING FOR CLIP TO MOVE, INDEX: " << clipIndex;
     bool checkLength = false;
     if (endTrack == startTrack) {
-        //mlt_service_lock(service.get_service());
         Mlt::Producer clipProducer(trackPlaylist.replace_with_blank(clipIndex));
         if (!trackPlaylist.is_blank_at(moveEnd) || clipProducer.is_blank()) {
             // error, destination is not empty
+            if (!trackPlaylist.is_blank_at(moveEnd)) trackPlaylist.insert_at(moveStart, clipProducer, 1);
             //int ix = trackPlaylist.get_clip_index_at(moveEnd);
             kDebug() << "// ERROR MOVING CLIP TO : " << moveEnd;
             mlt_service_unlock(m_mltConsumer->get_service());
@@ -2432,7 +2432,15 @@ bool Render::mltMoveClip(int startTrack, int endTrack, int moveStart, int moveEn
             QString currentid = clipProducer.parent().get("id");
             if (serv == "framebuffer" || currentid.endsWith("_video")) {
                 clip = &clipProducer;
-            } else clip = prod->cut(clipProducer.get_in(), clipProducer.get_out());
+            } else {
+                if (prod == NULL) {
+                    // Special case: prod is null when using placeholder clips.
+                    // in that case, use the producer existing in playlist. Note that
+                    // it will bypass the one producer per track logic and might cause
+                    // Sound cracks if clip is moved so that it overlaps another copy of itself
+                    clip = clipProducer.cut(clipProducer.get_in(), clipProducer.get_out());
+                } else clip = prod->cut(clipProducer.get_in(), clipProducer.get_out());
+            }
 
             // move all effects to the correct producer
             Mlt::Service clipService(clipProducer.get_service());