Skip to content

Commit

Permalink
Check project format version on load
Browse files Browse the repository at this point in the history
  • Loading branch information
rodlie committed Aug 14, 2024
1 parent f9a1be9 commit 2e8b0cf
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/app/evfileio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 2e8b0cf

Please sign in to comment.