From f6cbca73b639b4250db86bd32a3e1ef27c5ecd75 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Mon, 14 Feb 2011 01:57:49 +0000 Subject: [PATCH] Fix timeline corruption when creating new project with fps != default fps svn path=/trunk/kdenlive/; revision=5404 --- src/customtrackview.cpp | 5 +++-- src/monitor.cpp | 4 ++-- src/renderer.cpp | 21 +++++++++++++++++---- src/renderer.h | 1 + 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index bdefdf5b..b7cda93f 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -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) diff --git a/src/monitor.cpp b/src/monitor.cpp index bc75e187..dbe67719 100644 --- a/src/monitor.cpp +++ b/src/monitor.cpp @@ -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()); } } diff --git a/src/renderer.cpp b/src/renderer.cpp index c0a86da5..7c110a10 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -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", ">avformat-novalidate"); @@ -956,7 +970,6 @@ int Render::setSceneList(QString playlist, int position) playlist.replace(">avformat-novalidate", ">avformat"); 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); diff --git a/src/renderer.h b/src/renderer.h index c3c2959b..14a2186e 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -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; -- 2.39.2