Skip to content

Commit

Permalink
Save: ask if project format changes
Browse files Browse the repository at this point in the history
Ask before save if the project file format differs (breaking compatibility with older versions of Friction.

Also disable auto save if project version differs, requires you to save the file before auto save will work again.

This is needed to avoid accidental breakage of the project format version.
  • Loading branch information
rodlie committed Aug 14, 2024
1 parent 79d8bc9 commit c1a8273
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions src/app/GUI/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,21 @@ void MainWindow::checkAutoSaveTimer()
if (mAutoSave &&
mChangedSinceSaving &&
!mDocument.fEvFile.isEmpty())
{ saveFile(mDocument.fEvFile); }
{
const int projectVersion = AppSupport::getProjectVersion(mDocument.fEvFile);
const int newProjectVersion = AppSupport::getProjectVersion();
if (newProjectVersion > projectVersion && projectVersion > 0) {
QMessageBox::warning(this,
tr("Auto Save canceled"),
tr("Auto Save is not allowed to break"
" project format compatibility (%1 vs. %2)."
" Please save the project to confirm"
" project format changes.").arg(QString::number(newProjectVersion),
QString::number(projectVersion)));
return;
}
saveFile(mDocument.fEvFile);
}
}

void MainWindow::openAboutWindow()
Expand Down Expand Up @@ -2000,7 +2014,22 @@ void MainWindow::openFile(const QString& openPath)
void MainWindow::saveFile()
{
if (mDocument.fEvFile.isEmpty()) { saveFileAs(true); }
else { saveFile(mDocument.fEvFile); }
else {
const int projectVersion = AppSupport::getProjectVersion(mDocument.fEvFile);
const int newProjectVersion = AppSupport::getProjectVersion();
if (newProjectVersion > projectVersion && projectVersion > 0) {
const auto result = QMessageBox::question(this,
tr("Project version"),
tr("Saving this project file will change the project"
" format from version %1 to version %2."
" This breaks compatibility with older versions of Friction."
"\n\nAre you sure you want"
" to save this project file?").arg(QString::number(projectVersion),
QString::number(newProjectVersion)));
if (result != QMessageBox::Yes) { return; }
}
saveFile(mDocument.fEvFile);
}
}

void MainWindow::saveFile(const QString& path,
Expand Down

0 comments on commit c1a8273

Please sign in to comment.