From 0873b8d3046db38a8dbdde70a3d7f294c14dcf86 Mon Sep 17 00:00:00 2001 From: flow Date: Fri, 16 Sep 2022 20:02:21 -0300 Subject: [PATCH] fix: prevent container detaching in ResourceFolderModel and use const accessors whenever we can! Signed-off-by: flow --- launcher/minecraft/mod/ModFolderModel.cpp | 2 +- launcher/minecraft/mod/ResourceFolderModel.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/launcher/minecraft/mod/ModFolderModel.cpp b/launcher/minecraft/mod/ModFolderModel.cpp index 13fed1c9..9aca686f 100644 --- a/launcher/minecraft/mod/ModFolderModel.cpp +++ b/launcher/minecraft/mod/ModFolderModel.cpp @@ -234,7 +234,7 @@ auto ModFolderModel::allMods() -> QList { QList mods; - for (auto& res : m_resources) { + for (auto& res : qAsConst(m_resources)) { mods.append(static_cast(res.get())); } diff --git a/launcher/minecraft/mod/ResourceFolderModel.h b/launcher/minecraft/mod/ResourceFolderModel.h index 7edbe030..25095a45 100644 --- a/launcher/minecraft/mod/ResourceFolderModel.h +++ b/launcher/minecraft/mod/ResourceFolderModel.h @@ -247,7 +247,7 @@ void ResourceFolderModel::applyUpdates(QSet& current_set, QSet auto row = row_it.value(); auto& new_resource = new_resources[kept]; - auto const& current_resource = m_resources[row]; + auto const& current_resource = m_resources.at(row); if (new_resource->dateTimeChanged() == current_resource->dateTimeChanged()) { // no significant change, ignore... @@ -265,7 +265,7 @@ void ResourceFolderModel::applyUpdates(QSet& current_set, QSet } m_resources[row].reset(new_resource); - resolveResource(m_resources[row].get()); + resolveResource(m_resources.at(row).get()); emit dataChanged(index(row, 0), index(row, columnCount(QModelIndex()) - 1)); } } @@ -324,7 +324,7 @@ void ResourceFolderModel::applyUpdates(QSet& current_set, QSet { m_resources_index.clear(); int idx = 0; - for (auto const& mod : m_resources) { + for (auto const& mod : qAsConst(m_resources)) { m_resources_index[mod->internal_id()] = idx; idx++; }