From fc79d14657cffa1cb391aacb1a01d7d28b271b84 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Thu, 1 Oct 2009 14:43:12 +0000 Subject: [PATCH] * Correctly convert titles in existing projects to the new kdenlivetitle producer * Fix problem in document loading that caused some clips to be loaded twice and producer errors on load * upgrade document version to 0.85 svn path=/trunk/kdenlive/; revision=3973 --- src/documentvalidator.cpp | 66 +++++++++++++++++++++++++++++++++++++-- src/kdenlivedoc.cpp | 2 +- src/mainwindow.cpp | 2 +- 3 files changed, 66 insertions(+), 4 deletions(-) diff --git a/src/documentvalidator.cpp b/src/documentvalidator.cpp index bb6d8999..614fa1ca 100644 --- a/src/documentvalidator.cpp +++ b/src/documentvalidator.cpp @@ -144,7 +144,6 @@ bool DocumentValidator::upgrade(double version, const double currentVersion) KMessageBox::sorry(kapp->activeWindow(), i18n("This project type is unsupported (version %1) and can't be loaded.", version), i18n("Unable to open project")); return false; } - // QDomNode infoXmlNode = m_doc.elementsByTagName("kdenlivedoc").at(0); QDomElement infoXml = infoXmlNode.toElement(); @@ -721,10 +720,73 @@ bool DocumentValidator::upgrade(double version, const double currentVersion) } } + if (version <= 0.84) { + // update the title clips to use the new MLT kdenlivetitle producer + QDomNodeList kproducerNodes = m_doc.elementsByTagName("kdenlive_producer"); + for (int i = 0; i < kproducerNodes.count(); ++i) { + QDomElement kproducer = kproducerNodes.at(i).toElement(); + if (kproducer.attribute("type").toInt() == TEXT) { + QString data = kproducer.attribute("xmldata"); + QString datafile = kproducer.attribute("resource"); + if (!datafile.endsWith(".kdenlivetitle")) { + datafile = QString(); + kproducer.setAttribute("resource", QString()); + } + QString id = kproducer.attribute("id"); + QDomNodeList mltproducers = m_doc.elementsByTagName("producer"); + bool foundData = false; + bool foundResource = false; + bool foundService = false; + for (int j = 0; j < mltproducers.count(); j++) { + QDomElement wproducer = mltproducers.at(j).toElement(); + if (wproducer.attribute("id") == id) { + QDomNodeList props = wproducer.childNodes(); + for (int k = 0; k < props.count(); k++) { + if (props.at(k).toElement().attribute("name") == "xmldata") { + props.at(k).firstChild().setNodeValue(data); + foundData = true; + } + else if (props.at(k).toElement().attribute("name") == "mlt_service") { + props.at(k).firstChild().setNodeValue("kdenlivetitle"); + foundService = true; + } + else if (props.at(k).toElement().attribute("name") == "resource") { + props.at(k).firstChild().setNodeValue(datafile); + foundResource = true; + } + } + if (!foundData) { + QDomElement e = m_doc.createElement("property"); + e.setAttribute("name", "xmldata"); + QDomText value = m_doc.createTextNode(data); + e.appendChild(value); + wproducer.appendChild(e); + } + if (!foundService) { + QDomElement e = m_doc.createElement("property"); + e.setAttribute("name", "mlt_service"); + QDomText value = m_doc.createTextNode("kdenlivetitle"); + e.appendChild(value); + wproducer.appendChild(e); + } + if (!foundResource) { + QDomElement e = m_doc.createElement("property"); + e.setAttribute("name", "resource"); + QDomText value = m_doc.createTextNode(datafile); + e.appendChild(value); + wproducer.appendChild(e); + } + break; + } + } + } + } + } + + // The document has been converted: mark it as modified infoXml.setAttribute("version", currentVersion); m_modified = true; - return true; } diff --git a/src/kdenlivedoc.cpp b/src/kdenlivedoc.cpp index 632af144..0b3f05ab 100644 --- a/src/kdenlivedoc.cpp +++ b/src/kdenlivedoc.cpp @@ -45,7 +45,7 @@ #include -const double DOCUMENTVERSION = 0.84; +const double DOCUMENTVERSION = 0.85; KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, QString profileName, const QPoint tracks, Render *render, MainWindow *parent) : QObject(parent), diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8254082a..73261a24 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -1882,7 +1882,7 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //cha m_saveAction->setEnabled(doc->isModified()); m_activeDocument = doc; m_activeTimeline->updateProjectFps(); - m_projectList->updateAllClips(); + m_activeDocument->checkProjectClips(); if (KdenliveSettings::dropbframes()) slotUpdatePreviewSettings(); // set tool to select tool -- 2.39.5