From 9db27c6acc3310c9bd8cda31bcd13073eec4794e Mon Sep 17 00:00:00 2001 From: flow Date: Sat, 3 Sep 2022 13:26:06 -0300 Subject: [PATCH] fix: crash when adding resource packs directly in the folder This fixes an issue in which, when adding a new resource pack externally to PolyMC, when the resource pack view was open, would crash poly. Signed-off-by: flow --- launcher/minecraft/mod/ResourceFolderModel.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/launcher/minecraft/mod/ResourceFolderModel.h b/launcher/minecraft/mod/ResourceFolderModel.h index d763bec3..5652c156 100644 --- a/launcher/minecraft/mod/ResourceFolderModel.h +++ b/launcher/minecraft/mod/ResourceFolderModel.h @@ -257,8 +257,11 @@ void ResourceFolderModel::applyUpdates(QSet& current_set, QSet // If the resource is resolving, but something about it changed, we don't want to // continue the resolving. if (current_resource->isResolving()) { - auto task = (*m_active_parse_tasks.find(current_resource->resolutionTicket())).get(); - task->abort(); + auto ticket = current_resource->resolutionTicket(); + if (m_active_parse_tasks.contains(ticket)) { + auto task = (*m_active_parse_tasks.find(ticket)).get(); + task->abort(); + } } m_resources[row].reset(new_resource); @@ -285,8 +288,11 @@ void ResourceFolderModel::applyUpdates(QSet& current_set, QSet Q_ASSERT(removed_set.contains(removed_it->get()->internal_id())); if ((*removed_it)->isResolving()) { - auto task = (*m_active_parse_tasks.find((*removed_it)->resolutionTicket())).get(); - task->abort(); + auto ticket = (*removed_it)->resolutionTicket(); + if (m_active_parse_tasks.contains(ticket)) { + auto task = (*m_active_parse_tasks.find(ticket)).get(); + task->abort(); + } } beginRemoveRows(QModelIndex(), removed_index, removed_index);