diff --git a/vita3k/gui/src/settings.cpp b/vita3k/gui/src/settings.cpp index 2b43be8acb..6d6191ab9d 100644 --- a/vita3k/gui/src/settings.cpp +++ b/vita3k/gui/src/settings.cpp @@ -47,12 +47,9 @@ struct Theme { static std::map themes_info; static std::vector> themes_list; +static time_t last_updated_themes_list = 0; static void get_themes_list(GuiState &gui, EmuEnvState &emuenv) { - gui.themes_preview.clear(); - themes_info.clear(); - themes_list.clear(); - const auto theme_path{ emuenv.pref_path / "ux0/theme" }; const auto fw_theme_path{ emuenv.pref_path / "vs0/data/internal/theme" }; if ((!fs::exists(fw_theme_path) || fs::is_empty(fw_theme_path)) && (!fs::exists(theme_path) || fs::is_empty(theme_path))) { @@ -60,6 +57,17 @@ static void get_themes_list(GuiState &gui, EmuEnvState &emuenv) { return; } + // Check if the themes list has been updated recently to avoid unnecessary updates + if ((fs::last_write_time(theme_path) < last_updated_themes_list) && (fs::last_write_time(fw_theme_path) < last_updated_themes_list)) + return; + else if (last_updated_themes_list != 0) + LOG_INFO("Found new update of themes list, updating..."); + + // Clear all themes list + gui.themes_preview.clear(); + themes_info.clear(); + themes_list.clear(); + std::string user_lang; const auto sys_lang = static_cast(emuenv.cfg.sys_lang); switch (sys_lang) { @@ -180,6 +188,9 @@ static void get_themes_list(GuiState &gui, EmuEnvState &emuenv) { } } } + + // Update last updated themes list + last_updated_themes_list = time(0); } static std::string popup, menu, sub_menu, selected, title, delete_user_background, delete_theme;