diff --git a/src/backend/app/loot_settings.cpp b/src/backend/app/loot_settings.cpp index 1cf6d161..f0885d5a 100644 --- a/src/backend/app/loot_settings.cpp +++ b/src/backend/app/loot_settings.cpp @@ -195,7 +195,7 @@ namespace loot { void LootSettings::updateLastVersion() { std::lock_guard guard(mutex); - lastVersion = std::to_string(LootVersion::major) + "." + std::to_string(LootVersion::minor) + "." + std::to_string(LootVersion::patch); + lastVersion = LootVersion::string(); } YAML::Node LootSettings::toYaml() const { diff --git a/src/backend/app/loot_version.cpp.in b/src/backend/app/loot_version.cpp.in index 5c84c54b..530bec13 100644 --- a/src/backend/app/loot_version.cpp.in +++ b/src/backend/app/loot_version.cpp.in @@ -29,4 +29,8 @@ namespace loot { const unsigned int LootVersion::minor = 9; const unsigned int LootVersion::patch = 1; const std::string LootVersion::revision = "@GIT_COMMIT_STRING@"; + + std::string LootVersion::string() { + return std::to_string(major) + '.' + std::to_string(minor) + '.' + std::to_string(patch); + } } diff --git a/src/backend/app/loot_version.h b/src/backend/app/loot_version.h index d3d68d3f..0dab2f3c 100644 --- a/src/backend/app/loot_version.h +++ b/src/backend/app/loot_version.h @@ -34,6 +34,8 @@ namespace loot { static const unsigned int minor; static const unsigned int patch; static const std::string revision; + + static std::string string(); }; } diff --git a/src/gui/query_handler.cpp b/src/gui/query_handler.cpp index 801d33d1..07354e6a 100644 --- a/src/gui/query_handler.cpp +++ b/src/gui/query_handler.cpp @@ -566,7 +566,7 @@ namespace loot { std::string QueryHandler::GetVersion() { BOOST_LOG_TRIVIAL(info) << "Getting LOOT version."; - YAML::Node version(to_string(LootVersion::major) + "." + to_string(LootVersion::minor) + "." + to_string(LootVersion::patch) + "." + LootVersion::revision); + YAML::Node version(LootVersion::string() + "." + LootVersion::revision); return JSON::stringify(version); } diff --git a/src/tests/backend/app/loot_settings_test.h b/src/tests/backend/app/loot_settings_test.h index 3050b410..20eca1e2 100644 --- a/src/tests/backend/app/loot_settings_test.h +++ b/src/tests/backend/app/loot_settings_test.h @@ -45,7 +45,7 @@ namespace loot { }; TEST_F(LootSettingsTest, defaultConstructorShouldSetDefaultValues) { - const std::string currentVersion = std::to_string(LootVersion::major) + "." + std::to_string(LootVersion::minor) + "." + std::to_string(LootVersion::patch); + const std::string currentVersion = LootVersion::string(); const std::vector expectedGameSettings({ GameSettings(GameSettings::tes4), GameSettings(GameSettings::tes5), @@ -410,7 +410,7 @@ namespace loot { } TEST_F(LootSettingsTest, updateLastVersionShouldSetValueToCurrentLootVersion) { - const std::string currentVersion = std::to_string(LootVersion::major) + "." + std::to_string(LootVersion::minor) + "." + std::to_string(LootVersion::patch); + const std::string currentVersion = LootVersion::string(); YAML::Node inputYaml; inputYaml["lastVersion"] = "v0.7.1"; diff --git a/src/tests/backend/helpers/version_test.h b/src/tests/backend/helpers/version_test.h index 5ce5a158..989ab257 100644 --- a/src/tests/backend/helpers/version_test.h +++ b/src/tests/backend/helpers/version_test.h @@ -25,6 +25,7 @@ along with LOOT. If not, see #ifndef LOOT_TEST_BACKEND_HELPERS_VERSION #define LOOT_TEST_BACKEND_HELPERS_VERSION +#include "backend/app/loot_version.h" #include "backend/helpers/version.h" #include @@ -35,11 +36,7 @@ namespace loot { TEST(Version, shouldExtractVersionFromApiDll) { // Use the API DLL built. Version version(boost::filesystem::path("loot_api.dll")); - std::string expected( - std::to_string(LootVersion::major) + "." + - std::to_string(LootVersion::minor) + "." + - std::to_string(LootVersion::patch) + ".0" - ); + std::string expected(LootVersion::string() + ".0"); EXPECT_EQ(expected, version.AsString()); } #endif