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

Fix possible corruption on document saving (slash prepended to filename)

CCBUG: 374624
parent 7b28694e
......@@ -562,7 +562,7 @@ void KdenliveDoc::slotAutoSave()
qDebug() << "ERROR; CANNOT CREATE AUTOSAVE FILE";
}
//qDebug() << "// AUTOSAVE FILE: " << m_autosave->fileName();
QDomDocument sceneList = xmlSceneList(m_render->sceneList(m_url.adjusted(QUrl::RemoveFilename).toLocalFile()));
QDomDocument sceneList = xmlSceneList(m_render->sceneList(m_url.adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash).toLocalFile()));
if (sceneList.isNull()) {
//Make sure we don't save if scenelist is corrupted
KMessageBox::error(QApplication::activeWindow(), i18n("Cannot write to file %1, scene list is corrupted.", m_autosave->fileName()));
......@@ -1420,7 +1420,7 @@ void KdenliveDoc::loadDocumentProperties()
if (name == QStringLiteral("storagefolder")) {
// Make sure we have an absolute path
QString value = e.firstChild().nodeValue();
if (!value.startsWith(QStringLiteral("/"))) {
if (QFileInfo(value).isRelative()) {
value.prepend(root);
}
m_documentProperties.insert(name, value);
......
......@@ -3325,7 +3325,7 @@ void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QS
} else {
out = (int) GenTime(project->projectDuration()).frames(project->fps()) - 2;
}
QString playlistContent = pCore->projectManager()->projectSceneList(project->url().adjusted(QUrl::RemoveFilename).toLocalFile());
QString playlistContent = pCore->projectManager()->projectSceneList(project->url().adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash).toLocalFile());
if (!chapterFile.isEmpty()) {
QDomDocument doc;
QDomElement chapters = doc.createElement(QStringLiteral("chapters"));
......@@ -3398,7 +3398,10 @@ void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QS
// Do we want proxy rendering
if (project->useProxy() && !m_renderWidget->proxyRendering()) {
QString root = doc.documentElement().attribute(QStringLiteral("root")) + QStringLiteral("/");
QString root = doc.documentElement().attribute(QStringLiteral("root"));
if (!root.isEmpty()) {
root.append(QStringLiteral("/"));
}
// replace proxy clips with originals
//TODO
......@@ -3431,7 +3434,7 @@ void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QS
suffix.clear();
}
if (!producerResource.isEmpty()) {
if (!producerResource.startsWith(QLatin1Char('/'))) {
if (QFileInfo(producerResource).isRelative()) {
producerResource.prepend(root);
}
if (proxies.contains(producerResource)) {
......@@ -3648,7 +3651,7 @@ void MainWindow::slotArchiveProject()
QList <ClipController*> list = pCore->binController()->getControllerList();
KdenliveDoc *doc = pCore->projectManager()->current();
pCore->binController()->saveDocumentProperties(pCore->projectManager()->currentTimeline()->documentProperties(), doc->metadata(), pCore->projectManager()->currentTimeline()->projectView()->guidesData());
QDomDocument xmlDoc = doc->xmlSceneList(m_projectMonitor->sceneList(doc->url().adjusted(QUrl::RemoveFilename).path()));
QDomDocument xmlDoc = doc->xmlSceneList(m_projectMonitor->sceneList(doc->url().adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash).toLocalFile()));
QPointer<ArchiveWidget> d = new ArchiveWidget(doc->url().fileName(), xmlDoc, list, pCore->projectManager()->currentTimeline()->projectView()->extractTransitionsLumas(), this);
if (d->exec()) {
m_messageLabel->setMessage(i18n("Archiving project"), OperationCompletedMessage);
......
......@@ -707,7 +707,10 @@ bool ArchiveWidget::processProjectFile()
}
QDomElement mlt = m_doc.documentElement();
QString root = mlt.attribute(QStringLiteral("root")) + '/';
QString root = mlt.attribute(QStringLiteral("root"));
if (!root.isEmpty()) {
root.append(QStringLiteral("/"));
}
// Adjust global settings
QString basePath;
......
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