1
0
mirror of synced 2025-02-17 18:59:21 +01:00

fix: Race condition when loading projects while other providers are loaded already

This commit is contained in:
WerWolv 2024-06-27 17:10:42 +02:00
parent b1b54a5fe7
commit 82f1d08dd7

View File

@ -26,6 +26,8 @@
namespace hex::plugin::builtin {
static std::mutex s_openCloseMutex;
using namespace wolv::literals;
std::set<FileProvider*> 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);