fix: Occasional crash when loading project files
This commit is contained in:
parent
1698f1599b
commit
5f713882d4
@ -239,12 +239,13 @@ namespace hex {
|
||||
}
|
||||
|
||||
void TaskManager::collectGarbage() {
|
||||
{
|
||||
std::unique_lock lock1(s_queueMutex);
|
||||
std::unique_lock lock2(s_deferredCallsMutex);
|
||||
|
||||
std::erase_if(s_tasks, [](const auto &task) { return task->isFinished() && !task->hadException(); });
|
||||
}
|
||||
|
||||
if (s_tasks.empty()) {
|
||||
std::unique_lock lock2(s_deferredCallsMutex);
|
||||
for (auto &call : s_tasksFinishedCallbacks)
|
||||
call();
|
||||
s_tasksFinishedCallbacks.clear();
|
||||
|
@ -41,7 +41,18 @@ namespace hex::plugin::builtin {
|
||||
auto providerSettings = nlohmann::json::parse(tar.readString(basePath / hex::format("{}.json", id)));
|
||||
|
||||
auto provider = ImHexApi::Provider::createProvider(providerSettings["type"].get<std::string>(), true);
|
||||
ON_SCOPE_EXIT { if (!success) ImHexApi::Provider::remove(provider, true); };
|
||||
ON_SCOPE_EXIT {
|
||||
if (!success) {
|
||||
for (auto &task : TaskManager::getRunningTasks())
|
||||
task->interrupt();
|
||||
|
||||
TaskManager::runWhenTasksFinished([]{
|
||||
for (auto provider : ImHexApi::Provider::getProviders())
|
||||
ImHexApi::Provider::remove(provider, true);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (provider == nullptr) {
|
||||
success = false;
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user