diff --git a/app/core.cpp b/app/core.cpp index 4aa3a02de..4ed9f7d66 100644 --- a/app/core.cpp +++ b/app/core.cpp @@ -68,6 +68,7 @@ OLIVE_NAMESPACE_ENTER Core* Core::instance_ = nullptr; +const uint Core::kProjectVersion = 201003; Core::Core(const CoreParams& params) : main_window_(nullptr), diff --git a/app/core.h b/app/core.h index 71fa43b75..728f4e840 100644 --- a/app/core.h +++ b/app/core.h @@ -268,6 +268,8 @@ public: */ void CacheActiveSequence(bool in_out_only); + static const uint kProjectVersion; + public slots: /** * @brief Starts an open file dialog to load a project from file diff --git a/app/task/project/load/load.cpp b/app/task/project/load/load.cpp index 3d945023a..babfce5ff 100644 --- a/app/task/project/load/load.cpp +++ b/app/task/project/load/load.cpp @@ -25,6 +25,7 @@ #include #include "common/xmlutils.h" +#include "core.h" OLIVE_NAMESPACE_ENTER @@ -45,7 +46,17 @@ bool ProjectLoadTask::Run() if (reader.name() == QStringLiteral("olive")) { while(XMLReadNextStartElement(&reader)) { if (reader.name() == QStringLiteral("version")) { - qDebug() << "Project version:" << reader.readElementText(); + uint project_version = reader.readElementText().toUInt(); + + if (project_version > Core::kProjectVersion) { + // Project is newer than we support + SetError(tr("This project is newer than this version of Olive and cannot be opened.")); + return false; + } else if (project_version < 201003) { // Change this if we drop support for a project version + // Project is older than we support + SetError(tr("This project is from a version of Olive that is no longer supported in this version.")); + return false; + } } else if (reader.name() == QStringLiteral("project")) { ProjectPtr project = std::make_shared(); @@ -66,6 +77,11 @@ bool ProjectLoadTask::Run() reader.skipCurrentElement(); } } + } else if (reader.name() == QStringLiteral("project")) { + // 0.1 projects use "project" as the root instead of Olive. We don't currently support + // these projects + SetError(tr("This project is from a version of Olive that is no longer supported in this version.")); + return false; } else { reader.skipCurrentElement(); } diff --git a/app/task/project/save/save.cpp b/app/task/project/save/save.cpp index 211a70c2a..c4947ed31 100644 --- a/app/task/project/save/save.cpp +++ b/app/task/project/save/save.cpp @@ -25,6 +25,7 @@ #include #include "common/filefunctions.h" +#include "core.h" OLIVE_NAMESPACE_ENTER @@ -49,7 +50,9 @@ bool ProjectSaveTask::Run() writer.writeStartElement("olive"); - writer.writeTextElement("version", "0.2.0"); + // Version is stored in YYMMDD from whenever the project format was last changed + // Allows easy integer math for checking project versions. + writer.writeTextElement("version", QString::number(Core::kProjectVersion)); project_->Save(&writer);