[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdenlive] src: When adding a playlist clip in a project, check for missing files inside it
From: Jean-Baptiste Mardelle <jb () kdenlive ! org>
Date: 2016-11-29 8:10:29
Message-ID: E1cBdUj-0005jK-NT () code ! kde ! org
[Download RAW message or body]
Git commit d066c5357dd7d55c2ddf0ea6034610503e88a132 by Jean-Baptiste Mardelle.
Committed on 29/11/2016 at 08:01.
Pushed by mardelle into branch 'master'.
When adding a playlist clip in a project, check for missing files inside it
M +23 -0 src/bin/bin.cpp
M +8 -7 src/doc/documentchecker.cpp
https://commits.kde.org/kdenlive/d066c5357dd7d55c2ddf0ea6034610503e88a132
diff --git a/src/bin/bin.cpp b/src/bin/bin.cpp
index 5fbfa30..62e81f0 100644
--- a/src/bin/bin.cpp
+++ b/src/bin/bin.cpp
@@ -45,6 +45,7 @@ along with this program. If not, see \
<http://www.gnu.org/licenses/>. #include "project/invaliddialog.h"
#include "projectsortproxymodel.h"
#include "bincommands.h"
+#include "doc/documentchecker.h"
#include "mlt++/Mlt.h"
#include <QToolBar>
@@ -1046,6 +1047,28 @@ void Bin::createClip(QDomElement xml)
parentFolder = m_rootFolder;
}
}
+ QString path = EffectsList::property(xml, QStringLiteral("resource"));
+ if (path.endsWith(QStringLiteral(".mlt")) || \
path.endsWith(QStringLiteral(".kdenlive"))) { + QFile f(path);
+ QDomDocument doc;
+ doc.setContent(&f, false);
+ f.close();
+ DocumentChecker d(QUrl::fromLocalFile(path), doc);
+ if (!d.hasErrorInClips() && \
doc.documentElement().attribute(QStringLiteral("modified")) == QLatin1String("1")) { \
+ QString backupFile = path + QStringLiteral(".backup"); + \
KIO::FileCopyJob *copyjob = KIO::file_copy(QUrl::fromLocalFile(path), \
QUrl::fromLocalFile(backupFile)); + if (copyjob->exec()) {
+ if (!f.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ KMessageBox::sorry(this, i18n("Unable to write to file %1", \
path)); + } else {
+ QTextStream out(&f);
+ out << doc.toString();
+ f.close();
+ KMessageBox::information(this, i18n("Your project file was \
modified by Kdenlive.\nTo make sure you don't lose data, a backup copy called %1 was \
created.", backupFile)); + }
+ }
+ }
+ }
new ProjectClip(xml, m_blankThumb, parentFolder);
}
diff --git a/src/doc/documentchecker.cpp b/src/doc/documentchecker.cpp
index 0102363..a71a39c 100644
--- a/src/doc/documentchecker.cpp
+++ b/src/doc/documentchecker.cpp
@@ -802,6 +802,7 @@ void DocumentChecker::fixClipItem(QTreeWidgetItem *child, const \
QDomNodeList &pr int t = child->data(0, typeRole).toInt();
if (child->data(0, statusRole).toInt() == CLIPOK) {
QString id = child->data(0, idRole).toString();
+ QString fixedResource = child->text(1);
if (t == TITLE_IMAGE_ELEMENT) {
// edit images embedded in titles
for (int i = 0; i < producers.count(); ++i) {
@@ -813,7 +814,7 @@ void DocumentChecker::fixClipItem(QTreeWidgetItem *child, const \
QDomNodeList &pr property = properties.item(j).toElement();
if (property.attribute(QStringLiteral("name")) == \
QLatin1String("xmldata")) {
QString xml = property.firstChild().nodeValue();
- xml.replace(child->data(0, \
typeOriginalResource).toString(), child->text(1)); + \
xml.replace(child->data(0, typeOriginalResource).toString(), fixedResource); \
property.firstChild().setNodeValue(xml); break;
}
@@ -834,19 +835,19 @@ void DocumentChecker::fixClipItem(QTreeWidgetItem *child, const \
QDomNodeList &pr }*/
for (int i = 0; i < producers.count(); ++i) {
e = producers.item(i).toElement();
- if (e.attribute(QStringLiteral("id")).section('_', 0, 0) == id || \
e.attribute(QStringLiteral("id")).section(':', 1, 1) == id) { + if \
(e.attribute(QStringLiteral("id")).section('_', 0, 0) == id || \
e.attribute(QStringLiteral("id")).section(':', 1, 1) == id || \
e.attribute(QStringLiteral("id")) == id) { // Fix clip
QString resource = getProperty(e, QStringLiteral("resource"));
QString service = getProperty(e, QStringLiteral("mlt_service"));
- QString fixedResource = child->text(1);
+ QString updatedResource = fixedResource;
if \
(resource.contains(QRegExp("\\?[0-9]+\\.[0-9]+(&strobe=[0-9]+)?$"))) \
{
- fixedResource.append('?' + resource.section('?', -1));
+ updatedResource.append('?' + resource.section('?', -1));
}
if (service == QLatin1String("timewarp")) {
- setProperty(e, QStringLiteral("warp_resource"), \
fixedResource);
- fixedResource.prepend(getProperty(e, \
QStringLiteral("warp_speed")) + ":"); + setProperty(e, \
QStringLiteral("warp_resource"), updatedResource); + \
updatedResource.prepend(getProperty(e, QStringLiteral("warp_speed")) + ":"); }
- setProperty(e, QStringLiteral("resource"), fixedResource);
+ setProperty(e, QStringLiteral("resource"), updatedResource);
}
}
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic