Skip to content

Commit

Permalink
prevent crash when no valid savepoint directory has been choosen
Browse files Browse the repository at this point in the history
  • Loading branch information
chrxh committed Nov 8, 2024
1 parent e64930e commit 9a4f523
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion source/Gui/AutosaveWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ void AutosaveWindow::processStatusBar()
if (!_autosaveEnabled) {
return std::string("No autosave scheduled");
}
if (!_savepointTable.has_value()) {
return std::string("No valid directory");
}
auto secondsSinceLastAutosave = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now() - _lastAutosaveTimepoint);
return "Next autosave in " + StringHelper::format(std::chrono::seconds(_autosaveInterval * 60) - secondsSinceLastAutosave);
}();
Expand Down Expand Up @@ -359,7 +362,7 @@ void AutosaveWindow::processAutomaticSavepoints()
}

auto minSinceLastAutosave = std::chrono::duration_cast<std::chrono::minutes>(std::chrono::steady_clock::now() - _lastAutosaveTimepoint).count();
if (minSinceLastAutosave >= _autosaveInterval) {
if (minSinceLastAutosave >= _autosaveInterval && _savepointTable.has_value()) {
onCreateSavepoint(_catchPeaks != CatchPeaks_None);
_lastAutosaveTimepoint = std::chrono::steady_clock::now();
}
Expand Down

0 comments on commit 9a4f523

Please sign in to comment.