From 94dabdd0964b7fcdbc9a7914ab67679e025be9f8 Mon Sep 17 00:00:00 2001 From: XargonWan Date: Mon, 28 Oct 2024 11:26:54 +0900 Subject: [PATCH] Updated GuiMenu.cpp to correctly handle the RetroDECK version --- es-app/src/guis/GuiMenu.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/es-app/src/guis/GuiMenu.cpp b/es-app/src/guis/GuiMenu.cpp index 0d23c3a96..897fa14eb 100644 --- a/es-app/src/guis/GuiMenu.cpp +++ b/es-app/src/guis/GuiMenu.cpp @@ -2369,17 +2369,18 @@ void GuiMenu::addVersionInfo() #if defined(__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; + // Read version from /app/retrodeck/version if RETRODECK is defined + std::ifstream versionFile("/app/retrodeck/version"); + std::string retroDeckVersion; + + // Attempt to open the version file and read a line into retroDeckVersion; + // also check that the line is not empty to ensure valid version information + if (versionFile && std::getline(versionFile, retroDeckVersion) && !retroDeckVersion.empty()) { + mVersion.setText(applicationName + " " + retroDeckVersion); } 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" + retroDeckVersion = "UNKNOWN"; + mVersion.setText(applicationName + " " + retroDeckVersion); } #else // not RetroDECK