diff --git a/rpcs3/rpcs3qt/game_list_frame.h b/rpcs3/rpcs3qt/game_list_frame.h index c786768cae..86b7e63aca 100644 --- a/rpcs3/rpcs3qt/game_list_frame.h +++ b/rpcs3/rpcs3qt/game_list_frame.h @@ -97,25 +97,24 @@ Q_SIGNALS: void Refreshed(); public: - template struct GameIdsTable { - // List of Game IDS an operation has been done on for the use of the slot function - std::set m_done_ids; + // List of game paths an operation has been done on for the use of the slot function + std::set m_done_paths; }; - template + // Enqueue slot for refreshed signal + // Allowing for an individual container for each distinct use case (currently disabled and contains only one such entry) + template void AddRefreshedSlot(Func&& func) { - if (!m_refresh_funcs_manage_type.has_value()) - { - m_refresh_funcs_manage_type.emplace(); - } + // NOTE: Remove assert when the need for individual containers arises + static_assert(std::is_void_v); connect(this, &game_list_frame::Refreshed, this, [this, func = std::move(func)]() mutable { - func(m_refresh_funcs_manage_type->get>().m_done_ids); + func(m_refresh_funcs_manage_type->get>().m_done_paths); }, Qt::SingleShotConnection); } @@ -195,7 +194,6 @@ private: const std::array m_parsing_threads{0}; QFutureWatcher m_parsing_watcher; QFutureWatcher m_refresh_watcher; - usz m_refresh_counter = 0; QSet m_hidden_list; bool m_show_hidden{false}; @@ -213,5 +211,5 @@ private: bool m_draw_compat_status_to_grid = false; bool m_show_custom_icons = true; bool m_play_hover_movies = true; - std::optional> m_refresh_funcs_manage_type; + std::optional> m_refresh_funcs_manage_type{std::in_place}; }; diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index f77bf21030..8f755e152d 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -1095,27 +1095,30 @@ bool main_window::HandlePackageInstallation(QStringList file_paths, bool from_bo bootable_paths_installed[bootable_paths[index]] = packages[index].title_id; } + // Need to test here due to potential std::move later const bool installed_a_whole_package_without_new_software = bootable_paths_installed.empty() && !cancelled; if (!bootable_paths_installed.empty()) { - m_game_list_frame->AddRefreshedSlot([this, paths = std::move(bootable_paths_installed)](std::set& IDs) mutable + m_game_list_frame->AddRefreshedSlot([this, paths = std::move(bootable_paths_installed)](std::set& claimed_paths) mutable { // Try to claim operaions on ID for (auto it = paths.begin(); it != paths.end();) { - if (IDs.count(it->second)) + std::string resolved_path = Emu.GetCallbacks().resolve_path(it->first); + + if (resolved_path.empty() || claimed_paths.count(resolved_path)) { it = paths.erase(it); } else { - IDs.emplace(it->second); + claimed_paths.emplace(std::move(resolved_path)); it++; } } - ShowOptionalGamePreparations(tr("Success!"), tr("Successfully installed software from package(s)!"), std::move(paths)); + ShowOptionalGamePreparations(tr("Success!"), tr("Successfully installed software from package(s)!"), paths); }); } @@ -1127,12 +1130,6 @@ bool main_window::HandlePackageInstallation(QStringList file_paths, bool from_bo if (installed_a_whole_package_without_new_software) { m_gui_settings->ShowInfoBox(tr("Success!"), tr("Successfully installed software from package(s)!"), gui::ib_pkg_success, this); - return true; - } - - if (!cancelled) - { - return true; } } else @@ -2406,7 +2403,7 @@ void main_window::CreateConnects() // Only select one folder for now paths << QFileDialog::getExistingDirectory(this, tr("Select a folder containing one or more games"), qstr(fs::get_config_dir()), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); - AddGamesFromDirs(paths); + AddGamesFromDirs(std::move(paths)); }); connect(ui->bootRecentMenu, &QMenu::aboutToShow, this, [this]() @@ -3500,7 +3497,7 @@ void main_window::closeEvent(QCloseEvent* closeEvent) Add valid disc games to gamelist (games.yml) @param paths = dir paths to scan for game */ -void main_window::AddGamesFromDirs(const QStringList& paths) +void main_window::AddGamesFromDirs(QStringList&& paths) { if (paths.isEmpty()) { @@ -3508,7 +3505,7 @@ void main_window::AddGamesFromDirs(const QStringList& paths) } // Obtain list of previously existing entries under the specificied parent paths for comparison - std::unordered_set existing; + std::unordered_set existing; for (const game_info& game : m_game_list_frame->GetGameInfo()) { @@ -3530,7 +3527,7 @@ void main_window::AddGamesFromDirs(const QStringList& paths) Emu.AddGamesFromDir(sstr(path)); } - m_game_list_frame->AddRefreshedSlot([this, paths = std::move(paths), existing = std::move(existing)](std::set& IDs) + m_game_list_frame->AddRefreshedSlot([this, paths = std::move(paths), existing = std::move(existing)](std::set& claimed_paths) { // Execute followup operations only for newly added entries under the specified paths std::map paths_added; // -> title id @@ -3543,13 +3540,14 @@ void main_window::AddGamesFromDirs(const QStringList& paths) { if (Emu.IsPathInsideDir(game->info.path, sstr(dir_path))) { - // Try to claim operaion on ID - const QString title_id = qstr(game->info.serial); + // Try to claim operaion on directory path - if (!IDs.count(title_id)) + std::string resolved_path = Emu.GetCallbacks().resolve_path(game->info.path); + + if (!resolved_path.empty() && !claimed_paths.count(resolved_path)) { - IDs.emplace(title_id); - paths_added.emplace(game->info.path, title_id); + claimed_paths.emplace(game->info.path); + paths_added.emplace(game->info.path, qstr(game->info.serial)); } break; @@ -3560,7 +3558,7 @@ void main_window::AddGamesFromDirs(const QStringList& paths) if (!paths_added.empty()) { - ShowOptionalGamePreparations(tr("Success!"), tr("Successfully added software to game list from path(s)!"), std::move(paths_added)); + ShowOptionalGamePreparations(tr("Success!"), tr("Successfully added software to game list from path(s)!"), paths_added); } }); @@ -3741,7 +3739,7 @@ void main_window::dropEvent(QDropEvent* event) } case drop_type::drop_dir: // import valid games to gamelist (games.yaml) { - AddGamesFromDirs(drop_paths); + AddGamesFromDirs(std::move(drop_paths)); break; } case drop_type::drop_game: // import valid games to gamelist (games.yaml) diff --git a/rpcs3/rpcs3qt/main_window.h b/rpcs3/rpcs3qt/main_window.h index 45aaa7681c..7e4b8a167f 100644 --- a/rpcs3/rpcs3qt/main_window.h +++ b/rpcs3/rpcs3qt/main_window.h @@ -166,7 +166,7 @@ private: u64 m_drop_file_timestamp = umax; drop_type m_drop_file_cached_drop_type = drop_type::drop_error; drop_type IsValidFile(const QMimeData& md, QStringList* drop_paths = nullptr); - void AddGamesFromDirs(const QStringList& paths); + void AddGamesFromDirs(QStringList&& paths); QAction* CreateRecentAction(const q_string_pair& entry, const uint& sc_idx); void BootRecentAction(const QAction* act);