fix: prevent container detaching in ResourceFolderModel

and use const accessors whenever we can!

Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
flow 2022-09-16 20:02:21 -03:00
parent c9eb584ac8
commit 0873b8d304
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469
2 changed files with 4 additions and 4 deletions

View File

@ -234,7 +234,7 @@ auto ModFolderModel::allMods() -> QList<Mod*>
{
QList<Mod*> mods;
for (auto& res : m_resources) {
for (auto& res : qAsConst(m_resources)) {
mods.append(static_cast<Mod*>(res.get()));
}

View File

@ -247,7 +247,7 @@ void ResourceFolderModel::applyUpdates(QSet<QString>& current_set, QSet<QString>
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<QString>& current_set, QSet<QString>
}
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<QString>& current_set, QSet<QString>
{
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++;
}