diff --git a/plugins/builtin/source/content/providers/file_provider.cpp b/plugins/builtin/source/content/providers/file_provider.cpp index af1c2e8e8..5866716ba 100644 --- a/plugins/builtin/source/content/providers/file_provider.cpp +++ b/plugins/builtin/source/content/providers/file_provider.cpp @@ -26,6 +26,8 @@ namespace hex::plugin::builtin { + static std::mutex s_openCloseMutex; + using namespace wolv::literals; std::set FileProvider::s_openedFiles; @@ -247,6 +249,8 @@ namespace hex::plugin::builtin { ui::ToastInfo::open("hex.builtin.popup.error.read_only"_lang); } + std::scoped_lock lock(s_openCloseMutex); + m_file = std::move(file); m_fileStats = m_file.getFileInfo(); m_fileSize = m_file.getSize(); @@ -284,6 +288,8 @@ namespace hex::plugin::builtin { void FileProvider::close() { + std::scoped_lock lock(s_openCloseMutex); + m_file.close(); m_data.clear(); s_openedFiles.erase(this);