diff --git a/sphaira/include/title_info.hpp b/sphaira/include/title_info.hpp index 6cab976..5c5557f 100644 --- a/sphaira/include/title_info.hpp +++ b/sphaira/include/title_info.hpp @@ -50,9 +50,12 @@ struct ThreadResultData { using MetaEntries = std::vector; -// starts background thread. +// starts background thread (ref counted). Result Init(); +// closes the background thread. void Exit(); +// clears cache and empties the result array. +void Clear(); // adds new entry to queue. void PushAsync(u64 app_id); diff --git a/sphaira/source/title_info.cpp b/sphaira/source/title_info.cpp index c49089a..64c5e15 100644 --- a/sphaira/source/title_info.cpp +++ b/sphaira/source/title_info.cpp @@ -25,6 +25,7 @@ struct ThreadData { void Run(); void Close(); + void Clear(); void PushAsync(u64 id); auto GetAsync(u64 app_id) -> std::shared_ptr; @@ -185,6 +186,13 @@ void ThreadData::Close() { ueventSignal(&m_uevent); } +void ThreadData::Clear() { + SCOPED_MUTEX(&m_mutex_id); + SCOPED_MUTEX(&m_mutex_result); + m_result.clear(); + nxtcWipeCache(); +} + void ThreadData::PushAsync(u64 id) { SCOPED_MUTEX(&m_mutex_id); SCOPED_MUTEX(&m_mutex_result); @@ -294,14 +302,14 @@ auto ThreadData::Get(u64 app_id, bool* cached) -> std::shared_ptrstatus == NacpLoadStatus::Loaded) { - const auto tweek_path = GetContentsPath(app_id); - if (m_fs.DirExists(tweek_path)) { - log_write("[TITLE] found contents path: %s\n", tweek_path.s); + const auto tweak_path = GetContentsPath(app_id); + if (m_fs.DirExists(tweak_path)) { + log_write("[TITLE] found contents path: %s\n", tweak_path.s); std::vector icon; - m_fs.read_entire_file(fs::AppendPath(tweek_path, "icon.jpg"), icon); + m_fs.read_entire_file(fs::AppendPath(tweak_path, "icon.jpg"), icon); struct Overrides { std::string name; @@ -322,7 +330,7 @@ auto ThreadData::Get(u64 app_id, bool* cached) -> std::shared_ptr %zu\n", result->icon.size(), icon.size()); @@ -407,6 +415,13 @@ void Exit() { } } +void Clear() { + SCOPED_MUTEX(&g_mutex); + if (g_thread_data) { + g_thread_data->Clear(); + } +} + void PushAsync(u64 app_id) { SCOPED_MUTEX(&g_mutex); if (g_thread_data) { diff --git a/sphaira/source/ui/menus/game_menu.cpp b/sphaira/source/ui/menus/game_menu.cpp index 4a78ec3..b39eef6 100644 --- a/sphaira/source/ui/menus/game_menu.cpp +++ b/sphaira/source/ui/menus/game_menu.cpp @@ -26,7 +26,6 @@ #include #include #include -#include namespace sphaira::ui::menu::game { namespace { @@ -653,7 +652,7 @@ Menu::Menu(u32 flags) : grid::Menu{"Games"_i18n, flags} { "Back"_i18n, "Delete"_i18n, 0, [this](auto op_index){ if (op_index && *op_index) { m_dirty = true; - nxtcWipeCache(); + title::Clear(); App::PopToMenu(); } } diff --git a/sphaira/source/ui/menus/save_menu.cpp b/sphaira/source/ui/menus/save_menu.cpp index 3acb72c..cccc4f0 100644 --- a/sphaira/source/ui/menus/save_menu.cpp +++ b/sphaira/source/ui/menus/save_menu.cpp @@ -29,7 +29,6 @@ #include #include #include -#include namespace sphaira::ui::menu::save { namespace {