]> git.sesse.net Git - kdenlive/commitdiff
Fix corruption when changing project's fps
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 13 Jun 2011 17:04:40 +0000 (17:04 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Mon, 13 Jun 2011 17:04:40 +0000 (17:04 +0000)
svn path=/trunk/kdenlive/; revision=5710

src/clipmanager.cpp
src/clipmanager.h
src/docclipbase.cpp
src/docclipbase.h
src/kdenlivedoc.cpp
src/kdenlivedoc.h
src/mainwindow.cpp
src/projectlist.cpp
src/projectlist.h
src/renderer.cpp
src/renderer.h

index d234abb20704bf1e72111198511302a1326ba686..a1ebafcb7f97ac29b08882b95d162b3e3b47716a 100644 (file)
@@ -233,10 +233,10 @@ void ClipManager::clearUnusedProducers()
     }
 }
 
-void ClipManager::resetProducersList(const QList <Mlt::Producer *> prods, bool displayRatioChanged)
+void ClipManager::resetProducersList(const QList <Mlt::Producer *> 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 <Mlt::Producer *> 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)
index b96abf06ca8720cae18a471f9b3590a07c4fd605..b9374d2156cc04ae3c128e9cdee3571b7010007b 100644 (file)
@@ -95,7 +95,7 @@ Q_OBJECT public:
     void askForAudioThumb(const QString &id);
     QString projectFolder() const;
     void clearUnusedProducers();
-    void resetProducersList(const QList <Mlt::Producer *> prods, bool displayRatioChanged);
+    void resetProducersList(const QList <Mlt::Producer *> 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
index fc4c12c078109a44f44041693cca814d4f1eaa61..f7b88493b21ad190c155ac7ed1231ad500998f98 100644 (file)
@@ -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());
 }
index 6debdef711d4662e53b8d4fc53fe3734ff58aa5e..8c154ec0a0d350d2b46d33c0cc07e569d7b5048b 100644 (file)
@@ -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 */
index bac79c220bc08b53f6be84e86aff504d4e00d51a..cfd2a31c91a7c221442877aff5b940d0fa4bb274 100644 (file)
@@ -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()
index 5c4272399f10995e9a60dc59d519ebc3ec83c0ee..958c59cf505611dc1a79220f5a440f2b627e4c31 100644 (file)
@@ -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();
index 9e369e30aa143aab4a13057e8d54bd9c322164c8..5b7cedf62f9fb84dcd06c160fc8501896e56f587 100644 (file)
@@ -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()));
index a9087e4e32d4b7ff696843e8c675f75da2bbe403..5267348a3dafca4ee715754b50425b2b96a30dde 100644 (file)
@@ -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 <ProjectItem *>(*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 <DocClipBase*> ProjectList::documentClipList() const
index ab749372163fdb451fbf64a7aa676dec6f43e274..5c6ec30bb364830168cb96e04ff0fb84f68ecea8 100644 (file)
@@ -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);
index 3e18730174c408034b15898a708d2a7d5a72019b..6fc3a253a3fdbf8a3b3902a09fea5ea69dd8a1c2 100644 (file)
@@ -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);
 }
 
 
index 2be48efb9410d90850287b5cd43a58c1cc1fb8cf..d0a323db0c9106620af54702374c428a25da07b7 100644 (file)
@@ -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.
      *