Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

When adding a playlist clip in a project, check for missing files inside it

parent b2235e3f
......@@ -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);
}
......
......@@ -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));
}
......
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