From 8f5e052c9e08b360774533439c254a58ebee431a Mon Sep 17 00:00:00 2001 From: XargonWan Date: Mon, 23 Sep 2024 21:09:28 +0900 Subject: [PATCH] Trying to fix the version not showing correctly -fix2 --- es-app/src/guis/GuiMenu.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index d221e39ef..9eb61d5f2 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -2330,6 +2330,18 @@ void GuiMenu::addVersionInfo() mVersion.setColor(mMenuColorTertiary); const std::string applicationName {"RetroDECK"}; + std::ifstream file("/app/retrodeck/version"); + std::string version; + if (file.is_open() && std::getline(file, version) && !version.empty()) { + file.close(); + #undef PROGRAM_VERSION_STRING + #define PROGRAM_VERSION_STRING version.c_str() + std::cout << "Version read from file: " << PROGRAM_VERSION_STRING << std::endl; + } else { + std::cerr << "Error: Cannot read version from file or file is empty!" << std::endl; + // Set a default value in case the file can't be read + #define PROGRAM_VERSION_STRING "UNKNOWN" + } #if defined(IS_PRERELEASE) #if defined(__ANDROID__) @@ -2344,19 +2356,9 @@ void GuiMenu::addVersionInfo() mVersion.setText(applicationName + " " + Utils::String::toUpper(PROGRAM_VERSION_STRING) + "-" + std::to_string(ANDROID_VERSION_CODE)); #else - std::ifstream file("/app/retrodeck/version"); - std::string version; - std::getline(file, version); - file.close(); - #undef PROGRAM_VERSION_STRING - #define PROGRAM_VERSION_STRING version.c_str() - std::cout << PROGRAM_VERSION_STRING << std::endl; mVersion.setText(applicationName + " " + Utils::String::toUpper(PROGRAM_VERSION_STRING)); #endif #endif - - mVersion.setHorizontalAlignment(ALIGN_CENTER); - addChild(&mVersion); } void GuiMenu::openThemeDownloader(GuiSettings* settings)