From a688f87f557ab34ae8f7ef1353fc608e9314490b Mon Sep 17 00:00:00 2001 From: Adrian <78108584+AdrianCassar@users.noreply.github.com> Date: Thu, 23 May 2024 23:31:04 +0100 Subject: [PATCH] [VFS] Clear registered devices if launch failed --- src/xenia/app/emulator_window.cc | 2 ++ src/xenia/vfs/virtual_file_system.cc | 4 ++++ src/xenia/vfs/virtual_file_system.h | 2 ++ 3 files changed, 8 insertions(+) diff --git a/src/xenia/app/emulator_window.cc b/src/xenia/app/emulator_window.cc index a5cf3f90d..779d1aa1c 100644 --- a/src/xenia/app/emulator_window.cc +++ b/src/xenia/app/emulator_window.cc @@ -1740,6 +1740,8 @@ xe::X_STATUS EmulatorWindow::RunTitle(std::filesystem::path path_to_file) { xe::ui::ImGuiDialog::ShowMessageBox( imgui_drawer_.get(), "Title Launch Failed!", "Failed to launch title.\n\nCheck xenia.log for technical details."); + + emulator_->file_system()->Clear(); } else { AddRecentlyLaunchedTitle(path_to_file, emulator_->title_name()); diff --git a/src/xenia/vfs/virtual_file_system.cc b/src/xenia/vfs/virtual_file_system.cc index 35bf78bf3..077dc1e61 100644 --- a/src/xenia/vfs/virtual_file_system.cc +++ b/src/xenia/vfs/virtual_file_system.cc @@ -27,6 +27,10 @@ VirtualFileSystem::VirtualFileSystem() {} VirtualFileSystem::~VirtualFileSystem() { // Delete all devices. // This will explode if anyone is still using data from them. + Clear(); +} + +void VirtualFileSystem::Clear() { devices_.clear(); symlinks_.clear(); } diff --git a/src/xenia/vfs/virtual_file_system.h b/src/xenia/vfs/virtual_file_system.h index 3b83501bc..46c42c0c1 100644 --- a/src/xenia/vfs/virtual_file_system.h +++ b/src/xenia/vfs/virtual_file_system.h @@ -28,6 +28,8 @@ class VirtualFileSystem { VirtualFileSystem(); ~VirtualFileSystem(); + void Clear(); + bool RegisterDevice(std::unique_ptr device); bool UnregisterDevice(const std::string_view path);