From b1d68d8d883f9602f84b7c8a12d73baba63b52d0 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Mon, 13 Jun 2011 17:04:40 +0000 Subject: [PATCH] Fix corruption when changing project's fps svn path=/trunk/kdenlive/; revision=5710 --- src/clipmanager.cpp | 8 ++++---- src/clipmanager.h | 4 ++-- src/docclipbase.cpp | 30 ++++++++++++++++++++++++------ src/docclipbase.h | 2 +- src/kdenlivedoc.cpp | 4 ++-- src/kdenlivedoc.h | 2 +- src/mainwindow.cpp | 4 ++-- src/projectlist.cpp | 15 +++++++++++---- src/projectlist.h | 2 +- src/renderer.cpp | 5 ++--- src/renderer.h | 2 +- 11 files changed, 51 insertions(+), 27 deletions(-) diff --git a/src/clipmanager.cpp b/src/clipmanager.cpp index d234abb2..a1ebafcb 100644 --- a/src/clipmanager.cpp +++ b/src/clipmanager.cpp @@ -233,10 +233,10 @@ void ClipManager::clearUnusedProducers() } } -void ClipManager::resetProducersList(const QList prods, bool displayRatioChanged) +void ClipManager::resetProducersList(const QList prods, bool displayRatioChanged, bool fpsChanged) { for (int i = 0; i < m_clipList.count(); i++) { - if (m_clipList.at(i)->numReferences() > 0) { + if (m_clipList.at(i)->numReferences() > 0 || displayRatioChanged || fpsChanged) { m_clipList.at(i)->deleteProducers(true); } } @@ -246,10 +246,10 @@ void ClipManager::resetProducersList(const QList prods, bool d if (id.contains('_')) id = id.section('_', 0, 0); DocClipBase *clip = getClipById(id); if (clip) { - clip->setProducer(prods.at(i)); + clip->setProducer(prods.at(i), false, true); } } - emit checkAllClips(displayRatioChanged); + emit checkAllClips(displayRatioChanged, fpsChanged); } void ClipManager::slotAddClipList(const KUrl::List urls, const QString group, const QString &groupId) diff --git a/src/clipmanager.h b/src/clipmanager.h index b96abf06..b9374d21 100644 --- a/src/clipmanager.h +++ b/src/clipmanager.h @@ -95,7 +95,7 @@ Q_OBJECT public: void askForAudioThumb(const QString &id); QString projectFolder() const; void clearUnusedProducers(); - void resetProducersList(const QList prods, bool displayRatioChanged); + void resetProducersList(const QList prods, bool displayRatioChanged, bool fpsChanged); void addFolder(const QString&, const QString&); void deleteFolder(const QString&); void clear(); @@ -135,7 +135,7 @@ signals: void modifiedClip(const QString &); void missingClip(const QString &); void availableClip(const QString &); - void checkAllClips(bool displayRatioChanged); + void checkAllClips(bool displayRatioChanged, bool fpsChanged); }; #endif diff --git a/src/docclipbase.cpp b/src/docclipbase.cpp index fc4c12c0..f7b88493 100644 --- a/src/docclipbase.cpp +++ b/src/docclipbase.cpp @@ -458,7 +458,7 @@ void DocClipBase::setValid() m_placeHolder = false; } -void DocClipBase::setProducer(Mlt::Producer *producer, bool reset) +void DocClipBase::setProducer(Mlt::Producer *producer, bool reset, bool readPropertiesFromProducer) { if (producer == NULL || (m_placeHolder && !reset)) return; if (m_thumbProd && (reset || !m_thumbProd->hasProducer())) m_thumbProd->setProducer(producer); @@ -468,6 +468,7 @@ void DocClipBase::setProducer(Mlt::Producer *producer, bool reset) deleteProducers(false); } QString id = producer->get("id"); + bool updated = false; if (id.contains('_')) { // this is a subtrack producer, insert it at correct place id = id.section('_', 1); @@ -478,10 +479,16 @@ void DocClipBase::setProducer(Mlt::Producer *producer, bool reset) m_audioTrackProducers.append(NULL); } } - if (m_audioTrackProducers.at(pos) == NULL) m_audioTrackProducers[pos] = producer; + if (m_audioTrackProducers.at(pos) == NULL) { + m_audioTrackProducers[pos] = producer; + updated = true; + } return; } else if (id.endsWith("video")) { - m_videoOnlyProducer = producer; + if (m_videoOnlyProducer == NULL) { + m_videoOnlyProducer = producer; + updated = true; + } return; } int pos = id.toInt(); @@ -490,11 +497,22 @@ void DocClipBase::setProducer(Mlt::Producer *producer, bool reset) m_baseTrackProducers.append(NULL); } } - if (m_baseTrackProducers.at(pos) == NULL) m_baseTrackProducers[pos] = producer; + if (m_baseTrackProducers.at(pos) == NULL) { + m_baseTrackProducers[pos] = producer; + updated = true; + } } else { - if (m_baseTrackProducers.isEmpty()) m_baseTrackProducers.append(producer); - else if (m_baseTrackProducers.at(0) == NULL) m_baseTrackProducers[0] = producer; + if (m_baseTrackProducers.isEmpty()) { + m_baseTrackProducers.append(producer); + updated = true; + } + else if (m_baseTrackProducers.at(0) == NULL) { + m_baseTrackProducers[0] = producer; + updated = true; + } } + if (updated && readPropertiesFromProducer) + setDuration(GenTime(producer->get_length(), KdenliveSettings::project_fps())); //m_clipProducer = producer; //m_clipProducer->set("transparency", m_properties.value("transparency").toInt()); } diff --git a/src/docclipbase.h b/src/docclipbase.h index 6debdef7..8c154ec0 100644 --- a/src/docclipbase.h +++ b/src/docclipbase.h @@ -117,7 +117,7 @@ Q_OBJECT public: } /** Sets producers for the current clip (one for each track due to a limitation in MLT's track mixing */ - void setProducer(Mlt::Producer *producer, bool reset = false); + void setProducer(Mlt::Producer *producer, bool reset = false, bool readPropertiesFromProducer = false); /** Retrieve a producer for a track */ Mlt::Producer *producer(int track = -1); /** Retrieve the producer that shows only video */ diff --git a/src/kdenlivedoc.cpp b/src/kdenlivedoc.cpp index bac79c22..cfd2a31c 100644 --- a/src/kdenlivedoc.cpp +++ b/src/kdenlivedoc.cpp @@ -874,10 +874,10 @@ void KdenliveDoc::setRenderer(Render *render) { emit progressInfo(QString(), -1); }*/ -void KdenliveDoc::checkProjectClips(bool displayRatioChanged) +void KdenliveDoc::checkProjectClips(bool displayRatioChanged, bool fpsChanged) { if (m_render == NULL) return; - m_clipManager->resetProducersList(m_render->producersList(), displayRatioChanged); + m_clipManager->resetProducersList(m_render->producersList(), displayRatioChanged, fpsChanged); } Render *KdenliveDoc::renderer() diff --git a/src/kdenlivedoc.h b/src/kdenlivedoc.h index 5c427239..958c59cf 100644 --- a/src/kdenlivedoc.h +++ b/src/kdenlivedoc.h @@ -220,7 +220,7 @@ public slots: /** @brief Sets the document as modified or up to date. * @param mod (optional) true if the document has to be saved */ void setModified(bool mod = true); - void checkProjectClips(bool displayRatioChanged = false); + void checkProjectClips(bool displayRatioChanged = false, bool fpsChanged = false); private slots: void slotAutoSave(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 9e369e30..5b7cedf6 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2383,7 +2383,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //cha disconnect(m_projectList, SIGNAL(projectModified()), m_activeDocument, SLOT(setModified())); disconnect(m_projectList, SIGNAL(updateProfile(const QString &)), this, SLOT(slotUpdateProjectProfile(const QString &))); - disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool)), m_activeDocument, SLOT(checkProjectClips(bool))); + disconnect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), m_activeDocument, SLOT(checkProjectClips(bool, bool))); disconnect(m_activeDocument, SIGNAL(guidesUpdated()), this, SLOT(slotGuidesUpdated())); disconnect(m_activeDocument, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool))); @@ -2459,7 +2459,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //cha connect(m_projectMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified())); connect(m_clipMonitor, SIGNAL(zoneUpdated(QPoint)), doc, SLOT(setModified())); connect(m_projectMonitor, SIGNAL(durationChanged(int)), trackView, SLOT(setDuration(int))); - connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool)), doc, SLOT(checkProjectClips(bool))); + connect(m_projectMonitor->render, SIGNAL(refreshDocumentProducers(bool, bool)), doc, SLOT(checkProjectClips(bool, bool))); connect(doc, SIGNAL(addProjectClip(DocClipBase *, bool)), m_projectList, SLOT(slotAddClip(DocClipBase *, bool))); connect(doc, SIGNAL(resetProjectList()), m_projectList, SLOT(slotResetProjectList())); diff --git a/src/projectlist.cpp b/src/projectlist.cpp index a9087e4e..5267348a 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -1131,7 +1131,7 @@ void ProjectList::slotUpdateClip(const QString &id) monitorItemEditing(true); } -void ProjectList::updateAllClips(bool displayRatioChanged) +void ProjectList::updateAllClips(bool displayRatioChanged, bool fpsChanged) { m_listView->setSortingEnabled(false); @@ -1166,8 +1166,15 @@ void ProjectList::updateAllClips(bool displayRatioChanged) item = static_cast (*it); clip = item->referencedClip(); if (item->referencedClip()->producer() == NULL) { - if (clip->isPlaceHolder() == false) - requestClipInfo(clip->toXML(), clip->getId()); + if (clip->isPlaceHolder() == false) { + QDomElement xml = clip->toXML(); + if (fpsChanged) { + xml.removeAttribute("out"); + xml.removeAttribute("file_hash"); + xml.removeAttribute("proxy_out"); + } + requestClipInfo(xml, clip->getId()); + } else { item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled); if (item->data(0, Qt::DecorationRole).isNull()) { @@ -1475,7 +1482,7 @@ void ProjectList::setDocument(KdenliveDoc *doc) connect(m_doc->clipManager(), SIGNAL(modifiedClip(const QString &)), this, SLOT(slotModifiedClip(const QString &))); connect(m_doc->clipManager(), SIGNAL(missingClip(const QString &)), this, SLOT(slotMissingClip(const QString &))); connect(m_doc->clipManager(), SIGNAL(availableClip(const QString &)), this, SLOT(slotAvailableClip(const QString &))); - connect(m_doc->clipManager(), SIGNAL(checkAllClips(bool)), this, SLOT(updateAllClips(bool))); + connect(m_doc->clipManager(), SIGNAL(checkAllClips(bool, bool)), this, SLOT(updateAllClips(bool, bool))); } QList ProjectList::documentClipList() const diff --git a/src/projectlist.h b/src/projectlist.h index ab749372..5c6ec30b 100644 --- a/src/projectlist.h +++ b/src/projectlist.h @@ -209,7 +209,7 @@ public: public slots: void setDocument(KdenliveDoc *doc); - void updateAllClips(bool displayRatioChanged); + void updateAllClips(bool displayRatioChanged, bool fpsChanged); void slotReplyGetImage(const QString &clipId, const QPixmap &pix); void slotReplyGetFileProperties(const QString &clipId, Mlt::Producer *producer, const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata, bool replace, bool selectClip); void slotAddClip(DocClipBase *clip, bool getProperties); diff --git a/src/renderer.cpp b/src/renderer.cpp index 3e187301..6fc3a253 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -343,7 +343,7 @@ int Render::resetProfile(const QString profileName) //kDebug() << "//RESET WITHSCENE: " << scene; setSceneList(scene, pos); // producers have changed (different profile), so reset them... - emit refreshDocumentProducers(new_dar != current_dar); + emit refreshDocumentProducers(new_dar != current_dar, current_fps != new_fps); /*Mlt::Producer *producer = new Mlt::Producer(*m_mltProfile , "xml-string", scene.toUtf8().constData()); m_mltProducer = producer; m_blackClip = new Mlt::Producer(*m_mltProfile , "colour", "black"); @@ -576,7 +576,6 @@ void Render::getFileProperties(const QDomElement xml, const QString &clipId, int proxyProducer = false; } - KUrl url = KUrl(path); Mlt::Producer *producer = NULL; CLIPTYPE type = (CLIPTYPE)xml.attribute("type").toInt(); @@ -4022,7 +4021,7 @@ void Render::mltDeleteTrack(int ix) tractor.removeChild(track); //kDebug() << "/////////// RESULT SCENE: \n" << doc.toString(); setSceneList(doc.toString(), m_framePosition); - emit refreshDocumentProducers(false); + emit refreshDocumentProducers(false, false); } diff --git a/src/renderer.h b/src/renderer.h index 2be48efb..d0a323db 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -356,7 +356,7 @@ signals: * @param durationError Should be set to true if the proxy failed because it has not same length as original clip */ void removeInvalidProxy(const QString &id, bool durationError); - void refreshDocumentProducers(bool displayRatioChanged); + void refreshDocumentProducers(bool displayRatioChanged, bool fpsChanged); /** @brief A frame's image has to be shown. * -- 2.39.2