diff --git a/es-app/src/guis/GuiThemeDownloader.cpp b/es-app/src/guis/GuiThemeDownloader.cpp index e3c59bb87..ca6082728 100644 --- a/es-app/src/guis/GuiThemeDownloader.cpp +++ b/es-app/src/guis/GuiThemeDownloader.cpp @@ -9,6 +9,7 @@ #include "guis/GuiThemeDownloader.h" #include "EmulationStation.h" +#include "ThemeData.h" #include "components/MenuComponent.h" #include "resources/ResourceManager.h" @@ -25,6 +26,7 @@ GuiThemeDownloader::GuiThemeDownloader() , mFetching {false} , mLatestThemesList {false} , mAttemptedFetch {false} + , mHasThemeUpdates {false} , mFullscreenViewing {false} , mFullscreenViewerIndex {0} { @@ -173,6 +175,11 @@ GuiThemeDownloader::~GuiThemeDownloader() mFetchThread.join(); git_libgit2_shutdown(); + + if (mHasThemeUpdates) { + LOG(LogInfo) << "GuiThemeDownloader: There are updates, repopulating theme sets"; + ThemeData::populateThemeSets(); + } } bool GuiThemeDownloader::fetchRepository(const std::string& repositoryName, @@ -240,6 +247,8 @@ bool GuiThemeDownloader::fetchRepository(const std::string& repositoryName, git_reference_free(oldTargetRef); } git_buf_dispose(&buffer); + if (repositoryName != "themes-list") + mHasThemeUpdates = true; } errorCode = git_revparse_single(&object, repository, "FETCH_HEAD"); @@ -266,6 +275,8 @@ bool GuiThemeDownloader::fetchRepository(const std::string& repositoryName, errorCode = git_revparse_single(&objectHead, repository, "HEAD"); errorCode = git_reset(repository, objectHead, GIT_RESET_HARD, nullptr); git_object_free(objectHead); + if (repositoryName != "themes-list") + mHasThemeUpdates = true; } else { LOG(LogWarning) << "Repository \"" << repositoryName @@ -282,6 +293,8 @@ bool GuiThemeDownloader::fetchRepository(const std::string& repositoryName, LOG(LogInfo) << "Repository \"" << repositoryName << "\" contains local changes, performing hard reset"; resetRepository(repository); + if (repositoryName != "themes-list") + mHasThemeUpdates = true; } if (mergeAnalysis & GIT_MERGE_ANALYSIS_UP_TO_DATE) { @@ -344,8 +357,10 @@ bool GuiThemeDownloader::fetchRepository(const std::string& repositoryName, return true; } - if (repositoryName != "themes-list") + if (repositoryName != "themes-list") { mMessage = "THEME HAS BEEN UPDATED"; + mHasThemeUpdates = true; + } mPromise.set_value(true); return false; @@ -1087,6 +1102,9 @@ bool GuiThemeDownloader::cloneRepository(const std::string& repositoryName, cons return true; } + if (repositoryName != "themes-list") + mHasThemeUpdates = true; + mLatestThemesList = true; mPromise.set_value(true); return false; diff --git a/es-app/src/guis/GuiThemeDownloader.h b/es-app/src/guis/GuiThemeDownloader.h index dd8ab59c1..7301a5aa8 100644 --- a/es-app/src/guis/GuiThemeDownloader.h +++ b/es-app/src/guis/GuiThemeDownloader.h @@ -136,6 +136,7 @@ private: std::atomic mFetching; std::atomic mLatestThemesList; bool mAttemptedFetch; + bool mHasThemeUpdates; static inline std::atomic mReceivedObjectsProgress {0.0f}; static inline std::atomic mResolveDeltaProgress {0.0f}; std::vector mThemeSets; diff --git a/es-core/src/ThemeData.cpp b/es-core/src/ThemeData.cpp index 361311761..d67350c97 100644 --- a/es-core/src/ThemeData.cpp +++ b/es-core/src/ThemeData.cpp @@ -768,8 +768,7 @@ const ThemeData::ThemeElement* ThemeData::getElement(const std::string& view, void ThemeData::populateThemeSets() { - assert(sThemeSets.empty()); - + sThemeSets.clear(); LOG(LogInfo) << "Checking for available theme sets..."; // Check for themes first under the home directory, then under the data installation