fix: Occasional crash when loading project files

This commit is contained in:
WerWolv
2023-04-06 12:44:25 +02:00
parent 1698f1599b
commit 5f713882d4
2 changed files with 17 additions and 5 deletions

View File

@@ -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;