Skip to content

Commit

Permalink
simple version check
Browse files Browse the repository at this point in the history
  • Loading branch information
chrxh committed Feb 3, 2023
1 parent 0616c7b commit 51723b1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 9 additions & 1 deletion source/EngineInterface/Serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,14 +551,21 @@ namespace
{
std::vector<std::string> versionParts;
boost::split(versionParts, s, boost::is_any_of("."));
if (versionParts.size() < 3) {
return false;
}
try {
for (auto const& versionPart : versionParts) {
static_cast<void>(std::stoi(versionPart));
}
//simple check: will be improved in future
if (std::stoi(versionParts.front()) > 3) {
return false;
}
} catch (...) {
return false;
}
return versionParts.size() == 3;
return true;
}
struct VersionParts
{
Expand All @@ -583,6 +590,7 @@ void Serializer::deserializeDataDescription(ClusteredDataDescription& data, std:
throw std::runtime_error("No version detected.");
}
auto versionParts = getVersionParts(version);

if (versionParts.major <= 3 && versionParts.minor <= 2) {
DEPRECATED_ClusteredDataDescription_3_2 oldData;
archive(oldData);
Expand Down
5 changes: 4 additions & 1 deletion source/Gui/BrowserWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,10 @@ void _BrowserWindow::onOpenSimulation(std::string const& id)
}

DeserializedSimulation deserializedSim;
Serializer::deserializeSimulationFromStrings(deserializedSim, content, settings, symbolMap);
if (!Serializer::deserializeSimulationFromStrings(deserializedSim, content, settings, symbolMap)) {
MessageDialog::getInstance().show("Error", "Failed to load simulation. Your program version may not match.");
return;
}

_simController->closeSimulation();
_statisticsWindow->reset();
Expand Down

0 comments on commit 51723b1

Please sign in to comment.