From ed5aa4a67dee55edabf0065d471ba51ae90475c4 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Mon, 23 May 2022 00:12:21 +1000 Subject: [PATCH] Qt: Cancel game list scanning when VM starts Because of CDVD global state, and the fact that we hijack CDVD for getting the game details, we have to cancel the scan. Otherwise, the scanner will clash with the game's CDVD access. --- pcsx2-qt/MainWindow.cpp | 8 ++++++++ pcsx2/Frontend/GameList.cpp | 2 ++ pcsx2/VMManager.cpp | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/pcsx2-qt/MainWindow.cpp b/pcsx2-qt/MainWindow.cpp index 53bab7b29c..8e0202b06b 100644 --- a/pcsx2-qt/MainWindow.cpp +++ b/pcsx2-qt/MainWindow.cpp @@ -598,6 +598,10 @@ void MainWindow::updateEmulationActions(bool starting, bool running) if (!starting && !running) m_ui.actionPause->setChecked(false); + + // scanning needs to be disabled while running + m_ui.actionScanForNewGames->setDisabled(starting_or_running); + m_ui.actionRescanAllGames->setDisabled(starting_or_running); } void MainWindow::updateStatusBarWidgetVisibility() @@ -728,6 +732,10 @@ void MainWindow::switchToEmulationView() void MainWindow::refreshGameList(bool invalidate_cache) { + // can't do this while the VM is running because of CDVD + if (m_vm_valid) + return; + m_game_list_widget->refresh(invalidate_cache); } diff --git a/pcsx2/Frontend/GameList.cpp b/pcsx2/Frontend/GameList.cpp index 49e566a189..93ad09ed7d 100644 --- a/pcsx2/Frontend/GameList.cpp +++ b/pcsx2/Frontend/GameList.cpp @@ -494,6 +494,8 @@ void GameList::ScanDirectory(const char* path, bool recursive, const std::vector progress->SetProgressRange(static_cast(files.size())); progress->SetProgressValue(0); + u32 cached_files = 0; + for (FILESYSTEM_FIND_DATA& ffd : files) { if (progress->IsCancelled() || !GameList::IsScannableFilename(ffd.FileName) || diff --git a/pcsx2/VMManager.cpp b/pcsx2/VMManager.cpp index 2eae155704..5aa899494a 100644 --- a/pcsx2/VMManager.cpp +++ b/pcsx2/VMManager.cpp @@ -606,6 +606,12 @@ bool VMManager::Initialize(const VMBootParameters& boot_params) { const Common::Timer init_timer; pxAssertRel(s_state.load() == VMState::Shutdown, "VM is shutdown"); + + // cancel any game list scanning, we need to use CDVD! + // TODO: we can get rid of this once, we make CDVD not use globals... + // (or make it thread-local, but that seems silly.) + Host::CancelGameListRefresh(); + s_state.store(VMState::Initializing); Host::OnVMStarting();