From 2e8b0cfa9977fda0191628a8e510c4703c2d69ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Wed, 14 Aug 2024 23:22:01 +0200 Subject: [PATCH] Check project format version on load --- src/app/evfileio.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/app/evfileio.cpp b/src/app/evfileio.cpp index 5b185fb92..de374124d 100644 --- a/src/app/evfileio.cpp +++ b/src/app/evfileio.cpp @@ -69,14 +69,28 @@ #include "ReadWrite/evformat.h" #include "XML/runtimewriteid.h" -void MainWindow::loadEVFile(const QString &path) { +void MainWindow::loadEVFile(const QString &path) +{ QFile file(path); - if(!file.exists()) RuntimeThrow("File does not exist " + path); - if(!file.open(QIODevice::ReadOnly)) + if (!file.exists()) { RuntimeThrow("File does not exist " + path); } + if (!file.open(QIODevice::ReadOnly)) { RuntimeThrow("Could not open file " + path); + } try { const int evVersion = FileFooter::sReadEvFileVersion(&file); - if(evVersion <= 0) RuntimeThrow("Incompatible or incomplete data"); + if (evVersion <= 0) { RuntimeThrow("Incompatible or incomplete data"); } + + if (evVersion > EvFormat::version) { + QMessageBox::warning(this, + tr("Unsupported project version"), + tr("This project file (version %1) is not compatible" + " with this version of Friction," + " max supported project version is %2.").arg(QString::number(evVersion), + QString::number(EvFormat::version))); + file.close(); + return; + } + eReadStream readStream(evVersion, &file); readStream.setPath(path);