mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-21 21:55:38 +00:00
Updated GuiMenu.cpp to correctly handle the RetroDECK version
This commit is contained in:
parent
4436c8f5f6
commit
94dabdd096
|
@ -2369,17 +2369,18 @@ void GuiMenu::addVersionInfo()
|
||||||
|
|
||||||
|
|
||||||
#if defined(__RETRODECK__)
|
#if defined(__RETRODECK__)
|
||||||
std::ifstream file("/app/retrodeck/version");
|
// Read version from /app/retrodeck/version if RETRODECK is defined
|
||||||
std::string version;
|
std::ifstream versionFile("/app/retrodeck/version");
|
||||||
if (file.is_open() && std::getline(file, version) && !version.empty()) {
|
std::string retroDeckVersion;
|
||||||
file.close();
|
|
||||||
#undef PROGRAM_VERSION_STRING
|
// Attempt to open the version file and read a line into retroDeckVersion;
|
||||||
#define PROGRAM_VERSION_STRING version.c_str()
|
// also check that the line is not empty to ensure valid version information
|
||||||
std::cout << "Version read from file: " << PROGRAM_VERSION_STRING << std::endl;
|
if (versionFile && std::getline(versionFile, retroDeckVersion) && !retroDeckVersion.empty()) {
|
||||||
|
mVersion.setText(applicationName + " " + retroDeckVersion);
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "Error: Cannot read version from file or file is empty!" << std::endl;
|
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
|
retroDeckVersion = "UNKNOWN";
|
||||||
#define PROGRAM_VERSION_STRING "UNKNOWN"
|
mVersion.setText(applicationName + " " + retroDeckVersion);
|
||||||
}
|
}
|
||||||
#else // not RetroDECK
|
#else // not RetroDECK
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue