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

When aborting document load, open a new blank document

parent 0b8ac5a3
Pipeline #205284 passed with stage
in 7 minutes and 39 seconds
......@@ -259,7 +259,8 @@ DocOpenResult KdenliveDoc::Open(const QUrl &url, const QString &projectFolder, Q
DocumentChecker d(url, domDoc);
success = !d.hasErrorInClips();
if (!success) {
result.setError(i18n("Errors were detected in the project file."));
// Loading aborted
result.setAborted();
return result;
}
......
......@@ -52,6 +52,7 @@ class Profile;
class DocOpenResult {
public:
bool isSuccessful() const { return m_succeeded; }
bool isAborted() const { return m_aborted; }
/** @returns a unique_ptr to the KdenliveDoc, or an empty unique_ptr */
std::unique_ptr<KdenliveDoc> getDocument() { return std::move(m_doc); }
/** @returns an error message if the doc could not be opened. */
......@@ -65,6 +66,7 @@ public:
m_succeeded = true;
}
void setError(const QString &error) { m_errorMessage = error; }
void setAborted() { m_aborted = true; }
void setUpgraded(bool upgraded) { m_upgraded = upgraded; }
void setModified(bool modified) { m_modified = modified; }
......@@ -75,6 +77,7 @@ private:
bool m_upgraded = false;
bool m_modified = false;
bool m_succeeded = false;
bool m_aborted = false;
};
class KdenliveDoc : public QObject
......
......@@ -630,7 +630,7 @@ void ProjectManager::doOpenFile(const QUrl &url, KAutoSaveFile *stale, bool isBa
QString(), pCore->window()->m_commandStack, false, pCore->window());
KdenliveDoc *doc;
if (!openResult.isSuccessful()) {
if (!openResult.isSuccessful() && !openResult.isAborted()) {
if (!isBackup) {
int answer = KMessageBox::warningYesNoCancel(
pCore->window(), i18n("Cannot open the project file. Error:\n%1\nDo you want to open a backup file?", openResult.getError()),
......@@ -652,13 +652,15 @@ void ProjectManager::doOpenFile(const QUrl &url, KAutoSaveFile *stale, bool isBa
KMessageBox::detailedSorry(pCore->window(), "Could not open the backup project file.", openResult.getError());
}
} else {
doc = openResult.getDocument().release();
doc = openResult.getDocument().release();
}
// if we could not open the file, and could not recover (or user declined), stop now
if (!openResult.isSuccessful()) {
delete m_progressDialog;
m_progressDialog = nullptr;
// Open default blank document
newFile(false);
return;
}
......
Supports Markdown
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