summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <jb@kdenlive.org>2016-11-29 07:51:27 (GMT)
committerJean-Baptiste Mardelle <jb@kdenlive.org>2016-11-29 07:51:27 (GMT)
commit7d0240c8a82ba4cdbbbf4fd07b7746c645cb35f9 (patch)
tree6e69f631f45f9a58a1010ba47aa84b24a2cfd3d6
parentb2235e3ff5fea9c987752cdbd3899e87abedf4d0 (diff)
When adding a playlist clip in a project, check for missing files inside it
-rw-r--r--src/bin/bin.cpp23
-rw-r--r--src/doc/documentchecker.cpp6
2 files changed, 26 insertions, 3 deletions
diff --git a/src/bin/bin.cpp b/src/bin/bin.cpp
index 3da6f32..322b3ff 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 f6a111b..1f9def9 100644
--- a/src/doc/documentchecker.cpp
+++ b/src/doc/documentchecker.cpp
@@ -803,6 +803,7 @@ void DocumentChecker::fixClipItem(QTreeWidgetItem *child, QDomNodeList producers
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) {
@@ -814,7 +815,7 @@ void DocumentChecker::fixClipItem(QTreeWidgetItem *child, QDomNodeList producers
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;
}
@@ -835,11 +836,10 @@ void DocumentChecker::fixClipItem(QTreeWidgetItem *child, QDomNodeList producers
}*/
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, QLatin1String("resource"));
QString service = getProperty(e, QLatin1String("mlt_service"));
- QString fixedResource = child->text(1);
if (resource.contains(QRegExp("\\?[0-9]+\\.[0-9]+(&amp;strobe=[0-9]+)?$"))) {
fixedResource.append('?' + resource.section('?', -1));
}