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.
This commit is contained in:
Connor McLaughlin 2022-05-23 00:12:21 +10:00 committed by lightningterror
parent 22bf3549b6
commit ed5aa4a67d
3 changed files with 16 additions and 0 deletions

View File

@ -598,6 +598,10 @@ void MainWindow::updateEmulationActions(bool starting, bool running)
if (!starting && !running) if (!starting && !running)
m_ui.actionPause->setChecked(false); 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() void MainWindow::updateStatusBarWidgetVisibility()
@ -728,6 +732,10 @@ void MainWindow::switchToEmulationView()
void MainWindow::refreshGameList(bool invalidate_cache) 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); m_game_list_widget->refresh(invalidate_cache);
} }

View File

@ -494,6 +494,8 @@ void GameList::ScanDirectory(const char* path, bool recursive, const std::vector
progress->SetProgressRange(static_cast<u32>(files.size())); progress->SetProgressRange(static_cast<u32>(files.size()));
progress->SetProgressValue(0); progress->SetProgressValue(0);
u32 cached_files = 0;
for (FILESYSTEM_FIND_DATA& ffd : files) for (FILESYSTEM_FIND_DATA& ffd : files)
{ {
if (progress->IsCancelled() || !GameList::IsScannableFilename(ffd.FileName) || if (progress->IsCancelled() || !GameList::IsScannableFilename(ffd.FileName) ||

View File

@ -606,6 +606,12 @@ bool VMManager::Initialize(const VMBootParameters& boot_params)
{ {
const Common::Timer init_timer; const Common::Timer init_timer;
pxAssertRel(s_state.load() == VMState::Shutdown, "VM is shutdown"); 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); s_state.store(VMState::Initializing);
Host::OnVMStarting(); Host::OnVMStarting();