aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <[email protected]>2015-03-01 14:54:03 +0100
committerJean-Baptiste Mardelle <[email protected]>2015-03-01 15:20:03 +0100
commitc1d8b62660f797ae9f39b897f0600a31639a5499 (patch)
tree53fa8975d8e64c1ccb23efa748967e1c07093dc7
parentc00846b0193bf474152b754aa32ac97b10adc64c (diff)
Fix autosave not working (use real url instead of hash and don't start filename with a dot)
-rw-r--r--src/doc/kdenlivedoc.cpp16
-rw-r--r--src/project/projectmanager.cpp30
2 files changed, 21 insertions, 25 deletions
diff --git a/src/doc/kdenlivedoc.cpp b/src/doc/kdenlivedoc.cpp
index c65fb9d..4b348aa 100644
--- a/src/doc/kdenlivedoc.cpp
+++ b/src/doc/kdenlivedoc.cpp
@@ -340,7 +340,7 @@ KdenliveDoc::KdenliveDoc(const QUrl &url, const QUrl &projectFolder, QUndoGroup
infoXml.removeChild(markers);
}
- m_projectFolder = QUrl(infoXml.attribute("projectfolder"));
+ m_projectFolder = QUrl::fromLocalFile(infoXml.attribute("projectfolder"));
QDomElement docproperties = infoXml.firstChildElement("documentproperties");
QDomNamedNodeMap props = docproperties.attributes();
for (int i = 0; i < props.count(); ++i)
@@ -383,7 +383,7 @@ KdenliveDoc::KdenliveDoc(const QUrl &url, const QUrl &projectFolder, QUndoGroup
// Make sure the project folder is usable
if (m_projectFolder.isEmpty() || !QFile::exists(m_projectFolder.path())) {
KMessageBox::information(parent, i18n("Document project folder is invalid, setting it to the default one: %1", KdenliveSettings::defaultprojectfolder()));
- m_projectFolder = QUrl(KdenliveSettings::defaultprojectfolder());
+ m_projectFolder = QUrl::fromLocalFile(KdenliveSettings::defaultprojectfolder());
}
// Make sure that the necessary folders exist
@@ -825,7 +825,7 @@ bool KdenliveDoc::saveSceneList(const QString &path, const QString &scene, QMap
if (!autosave) {
cleanupBackupFiles();
QFileInfo info(file);
- QString fileName = QUrl(path).fileName().section('.', 0, -2);
+ QString fileName = QUrl::fromLocalFile(path).fileName().section('.', 0, -2);
fileName.append('-' + m_documentProperties.value("documentid"));
fileName.append(info.lastModified().toString("-yyyy-MM-dd-hh-mm"));
fileName.append(".kdenlive.png");
@@ -878,21 +878,21 @@ void KdenliveDoc::moveProjectData(const QUrl &url)
if (job->exec()) clip->setProperty("resource", newUrl.path());
}
QString hash = clip->getClipHash();
- QUrl oldVideoThumbUrl = QUrl(m_projectFolder.path() + QDir::separator() + "thumbs/" + hash + ".png");
+ QUrl oldVideoThumbUrl = QUrl::fromLocalFile(m_projectFolder.path() + QDir::separator() + "thumbs/" + hash + ".png");
if (QFile::exists(oldVideoThumbUrl.path())) {
cacheUrls << oldVideoThumbUrl;
}
- QUrl oldAudioThumbUrl = QUrl(m_projectFolder.path() + QDir::separator() + "thumbs/" + hash + ".thumb");
+ QUrl oldAudioThumbUrl = QUrl::fromLocalFile(m_projectFolder.path() + QDir::separator() + "thumbs/" + hash + ".thumb");
if (QFile::exists(oldAudioThumbUrl.path())) {
cacheUrls << oldAudioThumbUrl;
}
- QUrl oldVideoProxyUrl = QUrl(m_projectFolder.path() + QDir::separator() + "proxy/" + hash + '.' + KdenliveSettings::proxyextension());
+ QUrl oldVideoProxyUrl = QUrl::fromLocalFile(m_projectFolder.path() + QDir::separator() + "proxy/" + hash + '.' + KdenliveSettings::proxyextension());
if (QFile::exists(oldVideoProxyUrl.path())) {
cacheUrls << oldVideoProxyUrl;
}
}
if (!cacheUrls.isEmpty()) {
- KIO::Job *job = KIO::copy(cacheUrls, QUrl(url.path() + QDir::separator() + "thumbs/"));
+ KIO::Job *job = KIO::copy(cacheUrls, QUrl::fromLocalFile(url.path() + QDir::separator() + "thumbs/"));
KJobWidgets::setWindow(job, QApplication::activeWindow());
job->exec();
}
@@ -1749,7 +1749,7 @@ void KdenliveDoc::backupLastSavedVersion(const QString &path)
QDir backupFolder(m_projectFolder.path());
backupFolder.mkdir(".backup");
- QString fileName = QUrl(path).fileName().section('.', 0, -2);
+ QString fileName = QUrl::fromLocalFile(path).fileName().section('.', 0, -2);
QFileInfo info(file);
fileName.append('-' + m_documentProperties.value("documentid"));
fileName.append(info.lastModified().toString("-yyyy-MM-dd-hh-mm"));
diff --git a/src/project/projectmanager.cpp b/src/project/projectmanager.cpp
index 263fdb6..be7aa0f 100644
--- a/src/project/projectmanager.cpp
+++ b/src/project/projectmanager.cpp
@@ -99,7 +99,7 @@ void ProjectManager::newFile(bool showProjectSettings, bool force)
return;
}
// fix mantis#3160
- QUrl startFile = QUrl::fromLocalFile(KdenliveSettings::defaultprojectfolder() + "/.untitled.kdenlive");
+ QUrl startFile = QUrl::fromLocalFile(KdenliveSettings::defaultprojectfolder() + "/_untitled.kdenlive");
if (checkForBackupFile(startFile)) {
return;
}
@@ -145,8 +145,7 @@ void ProjectManager::newFile(bool showProjectSettings, bool force)
pCore->window()->m_timelineArea->setEnabled(true);
bool openBackup;
KdenliveDoc *doc = new KdenliveDoc(QUrl(), projectFolder, pCore->window()->m_commandStack, profileName, documentProperties, documentMetadata, projectTracks, pCore->monitorManager()->projectMonitor()->render, m_notesPlugin, &openBackup, pCore->window());
- QByteArray hash = QCryptographicHash::hash(startFile.toEncoded(), QCryptographicHash::Md5).toHex();
- doc->m_autosave = new KAutoSaveFile(QUrl(hash), doc);
+ doc->m_autosave = new KAutoSaveFile(startFile, doc);
bool ok;
pCore->bin()->setDocument(doc);
m_trackView = new TrackView(doc, pCore->window()->m_tracksActionCollection->actions(), &ok, pCore->window());
@@ -218,21 +217,20 @@ bool ProjectManager::saveFileAs(const QString &outputFileName)
m_trackView->projectView()->saveThumbnails();
m_project->setUrl(QUrl::fromLocalFile(outputFileName));
// setting up autosave file in ~/.kde/data/stalefiles/kdenlive/
- // saved under a crytopgraphic hash version of file name
+ // saved under file name
// actual saving by KdenliveDoc::slotAutoSave() called by a timer 3 seconds after the document has been edited
// This timer is set by KdenliveDoc::setModified()
- QByteArray hash = QCryptographicHash::hash(QUrl::fromLocalFile(outputFileName).toEncoded(), QCryptographicHash::Md5).toHex();
if (m_project->m_autosave == NULL) {
// The temporary file is not opened or created until actually needed.
// The file filename does not have to exist for KAutoSaveFile to be constructed (if it exists, it will not be touched).
- m_project->m_autosave = new KAutoSaveFile(QUrl(hash), this);
+ m_project->m_autosave = new KAutoSaveFile(QUrl::fromLocalFile(outputFileName), this);
} else {
- m_project->m_autosave->setManagedFile(QUrl(hash));
+ m_project->m_autosave->setManagedFile(QUrl::fromLocalFile(outputFileName));
}
pCore->window()->setWindowTitle(m_project->description());
m_project->setModified(false);
- m_recentFilesAction->addUrl(QUrl(outputFileName));
+ m_recentFilesAction->addUrl(QUrl::fromLocalFile(outputFileName));
m_fileRevert->setEnabled(true);
pCore->window()->m_undoView->stack()->setClean();
@@ -317,8 +315,7 @@ bool ProjectManager::checkForBackupFile(const QUrl &url)
{
// Check for backup file, saved under a hash filename.
// We only recover files that belong to the url we passed in.
- QByteArray hash = QCryptographicHash::hash(url.toEncoded(), QCryptographicHash::Md5).toHex();
- QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(QUrl(hash));
+ QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(url);
if (!staleFiles.isEmpty()) {
if (KMessageBox::questionYesNo(pCore->window(),
i18n("Auto-saved files exist. Do you want to recover them now?"),
@@ -348,7 +345,7 @@ void ProjectManager::openFile(const QUrl &url)
//qDebug()<<"Opening archive, processing";
QPointer<ArchiveWidget> ar = new ArchiveWidget(url);
if (ar->exec() == QDialog::Accepted) {
- openFile(QUrl(ar->extractedProjectFile()));
+ openFile(QUrl::fromLocalFile(ar->extractedProjectFile()));
} else if (m_startUrl.isValid()) {
// we tried to open an invalid file from command line, init new project
newFile(false);
@@ -405,7 +402,7 @@ void ProjectManager::doOpenFile(const QUrl &url, KAutoSaveFile *stale)
progressDialog.setValue(0);
bool openBackup;
- KdenliveDoc *doc = new KdenliveDoc(stale ? QUrl(stale->fileName()) : url, QUrl::fromLocalFile(KdenliveSettings::defaultprojectfolder()), pCore->window()->m_commandStack, KdenliveSettings::default_profile(), QMap <QString, QString> (), QMap <QString, QString> (), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), pCore->monitorManager()->projectMonitor()->render, m_notesPlugin, &openBackup, pCore->window(), &progressDialog);
+ KdenliveDoc *doc = new KdenliveDoc(stale ? QUrl::fromLocalFile(stale->fileName()) : url, QUrl::fromLocalFile(KdenliveSettings::defaultprojectfolder()), pCore->window()->m_commandStack, KdenliveSettings::default_profile(), QMap <QString, QString> (), QMap <QString, QString> (), QPoint(KdenliveSettings::videotracks(), KdenliveSettings::audiotracks()), pCore->monitorManager()->projectMonitor()->render, m_notesPlugin, &openBackup, pCore->window(), &progressDialog);
progressDialog.setValue(1);
progressDialog.setMaximum(4);
@@ -413,13 +410,12 @@ void ProjectManager::doOpenFile(const QUrl &url, KAutoSaveFile *stale)
progressDialog.repaint();
if (stale == NULL) {
- QByteArray hash = QCryptographicHash::hash(url.toEncoded(), QCryptographicHash::Md5).toHex();
- stale = new KAutoSaveFile(QUrl(hash), doc);
+ stale = new KAutoSaveFile(url, doc);
doc->m_autosave = stale;
} else {
doc->m_autosave = stale;
// if loading from an autosave of unnamed file then keep unnamed
- if (url.fileName().contains(".untitled.kdenlive"))
+ if (url.fileName().contains("_untitled.kdenlive"))
doc->setUrl(QUrl());
else
doc->setUrl(url);
@@ -510,7 +506,7 @@ void ProjectManager::slotOpenBackup(const QUrl& url)
QString projectId;
if (url.isValid()) {
// we could not open the project file, guess where the backups are
- projectFolder = QUrl(KdenliveSettings::defaultprojectfolder());
+ projectFolder = QUrl::fromLocalFile(KdenliveSettings::defaultprojectfolder());
projectFile = url;
} else {
projectFolder = m_project->projectFolder();
@@ -523,7 +519,7 @@ void ProjectManager::slotOpenBackup(const QUrl& url)
QString requestedBackup = dia->selectedFile();
m_project->backupLastSavedVersion(projectFile.path());
closeCurrentDocument(false);
- doOpenFile(QUrl(requestedBackup), NULL);
+ doOpenFile(QUrl::fromLocalFile(requestedBackup), NULL);
m_project->setUrl(projectFile);
m_project->setModified(true);
pCore->window()->setWindowTitle(m_project->description());