Commit 23e56b75 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix clip url not correctly updated when opening project with missing clips.

Related to #536
parent c05cd16b
...@@ -313,7 +313,7 @@ const QString ClipCreator::createClipsFromList(const QList<QUrl> &list, bool che ...@@ -313,7 +313,7 @@ const QString ClipCreator::createClipsFromList(const QList<QUrl> &list, bool che
if (checkRemovable && isOnRemovableDevice(file) && !isOnRemovableDevice(pCore->currentDoc()->projectDataFolder())) { if (checkRemovable && isOnRemovableDevice(file) && !isOnRemovableDevice(pCore->currentDoc()->projectDataFolder())) {
int answer = KMessageBox::warningContinueCancel( int answer = KMessageBox::warningContinueCancel(
QApplication::activeWindow(), QApplication::activeWindow(),
i18n("Clip <b>%1</b><br /> is on a removable device, will not be available when device is unplugged or mounted at a different position. You " i18n("Clip <b>%1</b><br /> is on a removable device, will not be available when device is unplugged or mounted at a different position.\nYou "
"may want to copy it first to your hard-drive. Would you like to add it anyways?", "may want to copy it first to your hard-drive. Would you like to add it anyways?",
file.path()), file.path()),
i18n("Removable device"), KStandardGuiItem::cont(), KStandardGuiItem::cancel(), QStringLiteral("confirm_removable_device")); i18n("Removable device"), KStandardGuiItem::cont(), KStandardGuiItem::cancel(), QStringLiteral("confirm_removable_device"));
......
...@@ -478,7 +478,7 @@ bool DocumentChecker::hasErrorInClips() ...@@ -478,7 +478,7 @@ bool DocumentChecker::hasErrorInClips()
QTreeWidgetItem *item = new QTreeWidgetItem(m_ui.treeWidget, QStringList() << clipType); QTreeWidgetItem *item = new QTreeWidgetItem(m_ui.treeWidget, QStringList() << clipType);
item->setData(0, statusRole, CLIPMISSING); item->setData(0, statusRole, CLIPMISSING);
item->setData(0, clipTypeRole, (int)type); item->setData(0, clipTypeRole, (int)type);
item->setData(0, idRole, e.attribute(QStringLiteral("id"))); item->setData(0, idRole, Xml::getXmlProperty(e, QStringLiteral("kdenlive:id")));
item->setToolTip(0, i18n("Missing item")); item->setToolTip(0, i18n("Missing item"));
if (status == TITLE_IMAGE_ELEMENT) { if (status == TITLE_IMAGE_ELEMENT) {
...@@ -644,7 +644,6 @@ bool DocumentChecker::hasErrorInClips() ...@@ -644,7 +644,6 @@ bool DocumentChecker::hasErrorInClips()
for (int i = 0; i < max; ++i) { for (int i = 0; i < max; ++i) {
QDomElement e = missingSources.at(i).toElement(); QDomElement e = missingSources.at(i).toElement();
QString realPath = Xml::getXmlProperty(e, QStringLiteral("kdenlive:originalurl")); QString realPath = Xml::getXmlProperty(e, QStringLiteral("kdenlive:originalurl"));
QString id = e.attribute(QStringLiteral("id"));
// Tell Kdenlive the source is missing // Tell Kdenlive the source is missing
e.setAttribute(QStringLiteral("_missingsource"), QStringLiteral("1")); e.setAttribute(QStringLiteral("_missingsource"), QStringLiteral("1"));
QTreeWidgetItem *subitem = new QTreeWidgetItem(item, QStringList() << i18n("Source clip")); QTreeWidgetItem *subitem = new QTreeWidgetItem(item, QStringList() << i18n("Source clip"));
...@@ -656,7 +655,7 @@ bool DocumentChecker::hasErrorInClips() ...@@ -656,7 +655,7 @@ bool DocumentChecker::hasErrorInClips()
subitem->setData(0, statusRole, CLIPMISSING); subitem->setData(0, statusRole, CLIPMISSING);
// int t = e.attribute("type").toInt(); // int t = e.attribute("type").toInt();
subitem->setData(0, typeRole, Xml::getXmlProperty(e, QStringLiteral("mlt_service"))); subitem->setData(0, typeRole, Xml::getXmlProperty(e, QStringLiteral("mlt_service")));
subitem->setData(0, idRole, id); subitem->setData(0, idRole, Xml::getXmlProperty(e, QStringLiteral("kdenlive:id")));
} }
} }
if (max > 0) { if (max > 0) {
...@@ -1067,6 +1066,7 @@ void DocumentChecker::fixClipItem(QTreeWidgetItem *child, const QDomNodeList &pr ...@@ -1067,6 +1066,7 @@ void DocumentChecker::fixClipItem(QTreeWidgetItem *child, const QDomNodeList &pr
QDomNodeList properties; QDomNodeList properties;
int t = child->data(0, typeRole).toInt(); int t = child->data(0, typeRole).toInt();
QString id = child->data(0, idRole).toString(); QString id = child->data(0, idRole).toString();
qDebug()<<"==== FIXING PRODUCER WITH ID: "<<id;
if (child->data(0, statusRole).toInt() == CLIPOK) { if (child->data(0, statusRole).toInt() == CLIPOK) {
QString fixedResource = child->text(1); QString fixedResource = child->text(1);
if (t == TITLE_IMAGE_ELEMENT) { if (t == TITLE_IMAGE_ELEMENT) {
...@@ -1110,12 +1110,12 @@ void DocumentChecker::fixClipItem(QTreeWidgetItem *child, const QDomNodeList &pr ...@@ -1110,12 +1110,12 @@ void DocumentChecker::fixClipItem(QTreeWidgetItem *child, const QDomNodeList &pr
}*/ }*/
for (int i = 0; i < producers.count(); ++i) { for (int i = 0; i < producers.count(); ++i) {
e = producers.item(i).toElement(); e = producers.item(i).toElement();
if (e.attribute(QStringLiteral("id")).section(QLatin1Char('_'), 0, 0) == id || if (Xml::getXmlProperty(e, QStringLiteral("kdenlive:id")) == id) {
e.attribute(QStringLiteral("id")).section(QLatin1Char(':'), 1, 1) == id || e.attribute(QStringLiteral("id")) == id) {
// Fix clip // Fix clip
QString resource = getProperty(e, QStringLiteral("resource")); QString resource = getProperty(e, QStringLiteral("resource"));
QString service = getProperty(e, QStringLiteral("mlt_service")); QString service = getProperty(e, QStringLiteral("mlt_service"));
QString updatedResource = fixedResource; QString updatedResource = fixedResource;
qDebug()<<"===== UPDATING RESOURCE FOR: "<<id<<": "<<resource<<" > "<<fixedResource;
if (resource.contains(QRegExp(QStringLiteral("\\?[0-9]+\\.[0-9]+(&amp;strobe=[0-9]+)?$")))) { if (resource.contains(QRegExp(QStringLiteral("\\?[0-9]+\\.[0-9]+(&amp;strobe=[0-9]+)?$")))) {
updatedResource.append(QLatin1Char('?') + resource.section(QLatin1Char('?'), -1)); updatedResource.append(QLatin1Char('?') + resource.section(QLatin1Char('?'), -1));
} }
...@@ -1131,7 +1131,7 @@ void DocumentChecker::fixClipItem(QTreeWidgetItem *child, const QDomNodeList &pr ...@@ -1131,7 +1131,7 @@ void DocumentChecker::fixClipItem(QTreeWidgetItem *child, const QDomNodeList &pr
// QString id = child->data(0, idRole).toString(); // QString id = child->data(0, idRole).toString();
for (int i = 0; i < producers.count(); ++i) { for (int i = 0; i < producers.count(); ++i) {
e = producers.item(i).toElement(); e = producers.item(i).toElement();
if (e.attribute("id") == id) { if (Xml::getXmlProperty(e, QStringLiteral("kdenlive:id")) == id) {
// Fix clip // Fix clip
setProperty(e, QStringLiteral("_placeholder"), QStringLiteral("1")); setProperty(e, QStringLiteral("_placeholder"), QStringLiteral("1"));
setProperty(e, QStringLiteral("kdenlive:orig_service"), getProperty(e, QStringLiteral("mlt_service"))); setProperty(e, QStringLiteral("kdenlive:orig_service"), getProperty(e, QStringLiteral("mlt_service")));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment