]> git.sesse.net Git - kdenlive/commitdiff
Fix timeline corruption when creating new project with fps != default fps
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 14 Feb 2011 01:57:49 +0000 (01:57 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 14 Feb 2011 01:57:49 +0000 (01:57 +0000)
svn path=/trunk/kdenlive/; revision=5404

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

index bdefdf5b61afc9fc0bc7b9f50c023af3cc63cdf5..b7cda93f09a83aed1f94e537cc4b39be3a801ebf 100644 (file)
@@ -373,6 +373,7 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
 {
     int pos = event->x();
     int mappedXPos = qMax((int)(mapToScene(event->pos()).x() + 0.5), 0);
+   
     double snappedPos = getSnapPointForPos(mappedXPos);
     emit mousePosition(mappedXPos);
 
@@ -3056,7 +3057,7 @@ void CustomTrackView::setCursorPos(int pos, bool seek)
     if (pos == m_cursorPos) return;
     emit cursorMoved((int)(m_cursorPos), (int)(pos));
     m_cursorPos = pos;
-    if (seek) m_document->renderer()->seek(GenTime(m_cursorPos, m_document->fps()));
+    if (seek) m_document->renderer()->seek(m_cursorPos);
     else if (m_autoScroll) checkScrolling();
     m_cursorLine->setPos(m_cursorPos, 0);
 }
@@ -3077,7 +3078,7 @@ void CustomTrackView::moveCursorPos(int delta)
     emit cursorMoved((int)(m_cursorPos), (int)((m_cursorPos + delta)));
     m_cursorPos += delta;
     m_cursorLine->setPos(m_cursorPos, 0);
-    m_document->renderer()->seek(GenTime(m_cursorPos, m_document->fps()));
+    m_document->renderer()->seek(m_cursorPos);
 }
 
 void CustomTrackView::initCursorPos(int pos)
index bc75e18703f807d6ade021846c4be0ad0c32be4a..dbe677190b43f481894b1b220723194d90836a8a 100644 (file)
@@ -817,10 +817,10 @@ void Monitor::slotSetXml(DocClipBase *clip, QPoint zone, const int position)
             // MLT CONSUMER is broken
             kDebug(QtWarningMsg) << "ERROR, Cannot start monitor";
         }
-    } else if (position != -1) render->seek(GenTime(position, m_monitorManager->timecode().fps()));
+    } else if (position != -1) render->seek(position);
     if (!zone.isNull()) {
         m_ruler->setZone(zone.x(), zone.y());
-        render->seek(GenTime(zone.x(), m_monitorManager->timecode().fps()));
+        render->seek(zone.x());
     }
 }
 
index c0a86da5a5b530d0446a62d1cace2c04ebfa3a62..7c110a10dabb64795540d861828b2a4d4486d3a3 100644 (file)
@@ -96,8 +96,8 @@ static void consumer_gl_frame_show(mlt_consumer, Render * self, mlt_frame frame_
 Render::Render(const QString & rendererName, int winid, QString profile, QWidget *parent) :
     QObject(parent),
     m_isBlocked(0),
-    sendFrameForAnalysis(false),
     analyseAudio(KdenliveSettings::monitor_audio()),
+    sendFrameForAnalysis(false),
     m_name(rendererName),
     m_mltConsumer(NULL),
     m_mltProducer(NULL),
@@ -355,6 +355,15 @@ void Render::seek(GenTime time)
     refresh();
 }
 
+void Render::seek(int time)
+{
+    if (!m_mltProducer)
+        return;
+    m_isBlocked = false;
+    m_mltProducer->seek(time);
+    refresh();
+}
+
 //static
 /*QPixmap Render::frameThumbnail(Mlt::Frame *frame, int width, int height, bool border) {
     QPixmap pix(width, height);
@@ -893,6 +902,13 @@ int Render::setSceneList(QString playlist, int position)
 
     //kDebug() << "//////  RENDER, SET SCENE LIST: " << playlist;
 
+    // Remove previous profile info
+    QDomDocument doc;
+    doc.setContent(playlist);
+    QDomElement profile = doc.documentElement().firstChildElement("profile");
+    doc.documentElement().removeChild(profile);
+    playlist = doc.toString();
+
     if (m_mltConsumer) {
         if (!m_mltConsumer->is_stopped()) {
             m_mltConsumer->stop();
@@ -907,7 +923,6 @@ int Render::setSceneList(QString playlist, int position)
         m_mltProducer->set_speed(0);
         //if (KdenliveSettings::osdtimecode() && m_osdInfo) m_mltProducer->detach(*m_osdInfo);
 
-
         Mlt::Service service(m_mltProducer->parent().get_service());
         mlt_service_lock(service.get_service());
 
@@ -948,7 +963,6 @@ int Render::setSceneList(QString playlist, int position)
     }
 
     blockSignals(true);
-
     // TODO: Better way to do this
     if (KdenliveSettings::projectloading_avformatnovalidate())
         playlist.replace(">avformat</property>", ">avformat-novalidate</property>");
@@ -956,7 +970,6 @@ int Render::setSceneList(QString playlist, int position)
         playlist.replace(">avformat-novalidate</property>", ">avformat</property>");
 
     m_mltProducer = new Mlt::Producer(*m_mltProfile, "xml-string", playlist.toUtf8().constData());
-
     if (!m_mltProducer || !m_mltProducer->is_valid()) {
         kDebug() << " WARNING - - - - -INVALID PLAYLIST: " << playlist.toUtf8().constData();
         m_mltProducer = m_blackClip->cut(0, 50);
index c3c2959b216206c87016b2b7081e54e48131501f..14a2186ec370d91c4fdbfbeea84ca9724487fae3 100644 (file)
@@ -91,6 +91,7 @@ Q_OBJECT public:
 
     /** @brief Seeks the renderer clip to the given time. */
     void seek(GenTime time);
+    void seek(int time);
     void seekToFrame(int pos);
     void seekToFrameDiff(int diff);
     int m_isBlocked;