Skip to content

Commit

Permalink
reset original after loading parameters: prevents crash when deleting…
Browse files Browse the repository at this point in the history
… zones
  • Loading branch information
chrxh committed Dec 1, 2024
1 parent c30a31a commit 3da8162
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions source/Gui/SimulationParametersWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2476,17 +2476,18 @@ void SimulationParametersWindow::onOpenParameters()
{
GenericFileDialog::get().showOpenFileDialog(
"Open simulation parameters", "Simulation parameters (*.parameters){.parameters},.*", _startingPath, [&](std::filesystem::path const& path) {
auto firstFilename = ifd::FileDialog::Instance().GetResult();
auto firstFilenameCopy = firstFilename;
_startingPath = firstFilenameCopy.remove_filename().string();

SimulationParameters parameters;
if (!SerializerService::get().deserializeSimulationParametersFromFile(parameters, firstFilename.string())) {
GenericMessageDialog::get().information("Open simulation parameters", "The selected file could not be opened.");
} else {
_simulationFacade->setSimulationParameters(parameters);
}
});
auto firstFilename = ifd::FileDialog::Instance().GetResult();
auto firstFilenameCopy = firstFilename;
_startingPath = firstFilenameCopy.remove_filename().string();

SimulationParameters parameters;
if (!SerializerService::get().deserializeSimulationParametersFromFile(parameters, firstFilename.string())) {
GenericMessageDialog::get().information("Open simulation parameters", "The selected file could not be opened.");
} else {
_simulationFacade->setSimulationParameters(parameters);
_simulationFacade->setOriginalSimulationParameters(parameters);
}
});
}

void SimulationParametersWindow::onSaveParameters()
Expand Down

0 comments on commit 3da8162

Please sign in to comment.