From 90b10ea22ef7ef0e0d8794a98030f9692a04894b Mon Sep 17 00:00:00 2001 From: UE4SS Date: Fri, 31 May 2024 22:52:28 +0200 Subject: [PATCH] fix(WinFile): File invalidation didn't take into account memory maps This made the move constructor useless if you memory mapped something because the destructor would always try to unmap which meant the map is no longer valid which meant it was impossible to pass around a memory map. --- assets/Changelog.md | 2 ++ deps/first/File/src/FileType/WinFile.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/assets/Changelog.md b/assets/Changelog.md index 41bd8e078..f1f0bcdcd 100644 --- a/assets/Changelog.md +++ b/assets/Changelog.md @@ -109,6 +109,8 @@ Fixed a crash caused by a race condition enabled by C++ mods using `UE4SS_ENABLE Fixed the `std::span` returned by `FileHandle::memory_map` being improperly sized. ([UE4SS #507](https://github.com/UE4SS-RE/RE-UE4SS/pull/507)) +Fixed 'File::Handle' unable to be moved if used in conjunction with memory_map. ([UE4SS #544](https://github.com/UE4SS-RE/RE-UE4SS/pull/544)) + ### BPModLoader Fixed "bad conversion" errors ([UE4SS #398](https://github.com/UE4SS-RE/RE-UE4SS/pull/398)) diff --git a/deps/first/File/src/FileType/WinFile.cpp b/deps/first/File/src/FileType/WinFile.cpp index 986253919..0cbfd2f84 100644 --- a/deps/first/File/src/FileType/WinFile.cpp +++ b/deps/first/File/src/FileType/WinFile.cpp @@ -20,6 +20,8 @@ namespace RC::File auto WinFile::invalidate_file() noexcept -> void { m_file = nullptr; + m_map_handle = nullptr; + m_memory_map = nullptr; } auto WinFile::delete_file(const std::filesystem::path& file_path_and_name) -> void