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 <flowlnlnln@gmail.com>
This commit is contained in:
flow 2022-09-03 13:26:06 -03:00
parent 42c81395b3
commit 9db27c6acc
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469

View File

@ -257,8 +257,11 @@ void ResourceFolderModel::applyUpdates(QSet<QString>& current_set, QSet<QString>
// 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<QString>& current_set, QSet<QString>
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);