Commit 78e4acad authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle

Merge branch '2008'

parents a4e44d72 9cac6b3b
Pipeline #27053 passed with stage
in 16 minutes and 7 seconds
......@@ -282,6 +282,7 @@ bool ProjectManager::closeCurrentDocument(bool saveChanges, bool quit)
m_project = nullptr;
}
}
m_mainTimelineModel.reset();
return true;
}
......@@ -428,6 +429,11 @@ bool ProjectManager::checkForBackupFile(const QUrl &url, bool newFile)
const QString projectId = QCryptographicHash::hash(url.fileName().toUtf8(), QCryptographicHash::Md5).toHex();
QUrl autosaveUrl = newFile ? url : QUrl::fromLocalFile(QFileInfo(url.path()).absoluteDir().absoluteFilePath(projectId + QStringLiteral(".kdenlive")));
QList<KAutoSaveFile *> staleFiles = KAutoSaveFile::staleFiles(autosaveUrl);
QFileInfo sourceInfo(url.toLocalFile());
QDateTime sourceTime;
if (sourceInfo.exists()) {
sourceTime = QFileInfo(url.toLocalFile()).lastModified();
}
KAutoSaveFile *orphanedFile = nullptr;
// Check if we can have a lock on one of the file,
// meaning it is not handled by any Kdenlive instance
......@@ -435,14 +441,16 @@ bool ProjectManager::checkForBackupFile(const QUrl &url, bool newFile)
for (KAutoSaveFile *stale : staleFiles) {
if (stale->open(QIODevice::QIODevice::ReadWrite)) {
// Found orphaned autosave file
orphanedFile = stale;
break;
if (!sourceTime.isValid() || QFileInfo(stale->fileName()).lastModified() > sourceTime) {
orphanedFile = stale;
break;
}
}
}
}
if (orphanedFile) {
if (KMessageBox::questionYesNo(nullptr, i18n("Auto-saved files exist. Do you want to recover them now?"), i18n("File Recovery"),
if (KMessageBox::questionYesNo(nullptr, i18n("Auto-saved file exist. Do you want to recover now?"), i18n("File Recovery"),
KGuiItem(i18n("Recover")), KGuiItem(i18n("Do not recover"))) == KMessageBox::Yes) {
doOpenFile(url, orphanedFile);
return true;
......
......@@ -90,6 +90,7 @@ TimelineController::~TimelineController()
void TimelineController::prepareClose()
{
// Clear roor so we don't call its methods anymore
QObject::disconnect( m_deleteConnection );
m_ready = false;
m_root = nullptr;
// Delete timeline preview before resetting model so that removing clips from timeline doesn't invalidate
......@@ -105,7 +106,7 @@ void TimelineController::setModel(std::shared_ptr<TimelineItemModel> model)
m_model = std::move(model);
m_activeSnaps.clear();
connect(m_model.get(), &TimelineItemModel::requestClearAssetView, pCore.get(), &Core::clearAssetPanel);
connect(m_model.get(), &TimelineItemModel::checkItemDeletion, [this] (int id) {
m_deleteConnection = connect(m_model.get(), &TimelineItemModel::checkItemDeletion, [this] (int id) {
if (m_ready) {
QMetaObject::invokeMethod(m_root, "checkDeletion", Qt::QueuedConnection, Q_ARG(QVariant, id));
}
......
......@@ -614,6 +614,7 @@ private:
std::vector<int> m_activeSnaps;
int m_snapStackIndex;
QMetaObject::Connection m_connection;
QMetaObject::Connection m_deleteConnection;
void initializePreview();
bool darkBackground() const;
......
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