diff --git a/es-app/src/SystemData.cpp b/es-app/src/SystemData.cpp index 1f359a3a5..0bbcac17f 100644 --- a/es-app/src/SystemData.cpp +++ b/es-app/src/SystemData.cpp @@ -1079,27 +1079,22 @@ std::string SystemData::getGamelistPath(bool forWrite) const std::string SystemData::getThemePath() const { - // Locations where we check for themes, in the following order: - // 1. [SYSTEM_PATH]/theme.xml - // 2. System theme from currently selected theme set [CURRENT_THEME_PATH]/[SYSTEM]/theme.xml - // 3. Default system theme from currently selected theme set [CURRENT_THEME_PATH]/theme.xml + // Check for the precence of [CURRENT_THEME_PATH]/[SYSTEM]/theme.xml and if this does not + // exist, then try the default for the theme set, i.e. [CURRENT_THEME_PATH]/theme.xml + std::string themePath {ThemeData::getThemeFromCurrentSet(mThemeFolder)}; - // First, check game folder. - std::string localThemePath = mRootFolder->getPath() + "/theme.xml"; - if (Utils::FileSystem::exists(localThemePath)) - return localThemePath; + if (Utils::FileSystem::exists(themePath)) + return themePath; - // Not in game folder, try system theme in theme sets. - localThemePath = ThemeData::getThemeFromCurrentSet(mThemeFolder); + themePath = Utils::FileSystem::getParent(Utils::FileSystem::getParent(themePath)); - if (Utils::FileSystem::exists(localThemePath)) - return localThemePath; + if (themePath != "") { + themePath.append("/theme.xml"); + if (Utils::FileSystem::exists(themePath)) + return themePath; + } - // Not system theme, try default system theme in theme set. - localThemePath = - Utils::FileSystem::getParent(Utils::FileSystem::getParent(localThemePath)) + "/theme.xml"; - - return localThemePath; + return ""; } SystemData* SystemData::getRandomSystem(const SystemData* currentSystem) @@ -1260,7 +1255,7 @@ void SystemData::loadTheme() { mTheme = std::make_shared(); - std::string path = getThemePath(); + std::string path {getThemePath()}; if (!Utils::FileSystem::exists(path)) { // No theme available for this platform. diff --git a/es-app/src/main.cpp b/es-app/src/main.cpp index eff59ad09..f0771aa0d 100644 --- a/es-app/src/main.cpp +++ b/es-app/src/main.cpp @@ -661,7 +661,7 @@ int main(int argc, char* argv[]) AudioManager::getInstance(); MameNames::getInstance(); - ThemeData::getThemeSets(); + ThemeData::populateThemeSets(); loadSystemsReturnCode loadSystemsStatus = loadSystemConfigFile(); if (loadSystemsStatus) { diff --git a/es-core/src/ThemeData.cpp b/es-core/src/ThemeData.cpp index aa44003ae..1e99f1e98 100644 --- a/es-core/src/ThemeData.cpp +++ b/es-core/src/ThemeData.cpp @@ -531,11 +531,9 @@ const ThemeData::ThemeElement* ThemeData::getElement(const std::string& view, return &elemIt->second; } -const std::map& -ThemeData::getThemeSets() +void ThemeData::populateThemeSets() { - if (!mThemeSets.empty()) - return mThemeSets; + assert(mThemeSets.empty()); LOG(LogInfo) << "Checking for available theme sets..."; @@ -583,8 +581,6 @@ ThemeData::getThemeSets() } } } - - return mThemeSets; } const std::string ThemeData::getThemeFromCurrentSet(const std::string& system) diff --git a/es-core/src/ThemeData.h b/es-core/src/ThemeData.h index af815c8a9..cc264bcd0 100644 --- a/es-core/src/ThemeData.h +++ b/es-core/src/ThemeData.h @@ -214,7 +214,11 @@ public: const std::string& element, const std::string& expectedType) const; - const static std::map& getThemeSets(); + static void populateThemeSets(); + const static std::map& getThemeSets() + { + return mThemeSets; + } const static std::string getThemeFromCurrentSet(const std::string& system); const static std::string getAspectRatioLabel(const std::string& aspectRatio);