diff --git a/Utilities/File.cpp b/Utilities/File.cpp index 057b8a1191..2713ef75ba 100644 --- a/Utilities/File.cpp +++ b/Utilities/File.cpp @@ -2479,10 +2479,13 @@ bool fs::pending_file::commit(bool overwrite) #endif #ifdef _WIN32 - // Disable auto-delete - FILE_DISPOSITION_INFO disp; - disp.DeleteFileW = false; - SetFileInformationByHandle(file.get_handle(), FileDispositionInfo, &disp, sizeof(disp)); + if (file) + { + // Disable auto-delete + FILE_DISPOSITION_INFO disp; + disp.DeleteFileW = false; + ensure(SetFileInformationByHandle(file.get_handle(), FileDispositionInfo, &disp, sizeof(disp))); + } #endif file.close(); diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 3aad1c4c2b..602a4b2b5c 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -3345,13 +3345,13 @@ void Emulator::Kill(bool allow_autoexit, bool savestate, savestate_stage* save_s set_progress_message("Commiting File"); - fs::file to_close_file; { + auto& ar = *to_ar->load(); auto reset = init_mtx->reset(); - to_close_file = std::move(file.file); + ar = {}; + ar.set_reading_state(); // Guard against using it reset.set_init(); } - to_close_file.close(); if (!file.commit() || !fs::get_stat(path, file_stat)) { diff --git a/rpcs3/rpcs3qt/gui_application.cpp b/rpcs3/rpcs3qt/gui_application.cpp index 35f7e7e255..a9c7ed8a4f 100644 --- a/rpcs3/rpcs3qt/gui_application.cpp +++ b/rpcs3/rpcs3qt/gui_application.cpp @@ -740,7 +740,7 @@ void gui_application::InitializeCallbacks() verbose_message = "\n" + *str_ptr; } - bytes_written = std::max(ar_ptr->get_size(), old_written); + bytes_written = ar_ptr->is_writing() ? std::max(ar_ptr->get_size(), old_written) : old_written; break; }