fix: prevent deletes by shared pointer accidental creation

This fixes the launcher crashing when opening the game :iea:

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

View File

@ -706,7 +706,7 @@ QStringList MinecraftInstance::verboseDescription(AuthSessionPtr session, Minecr
{ {
out << QString("%1:").arg(label); out << QString("%1:").arg(label);
auto modList = model.allMods(); auto modList = model.allMods();
std::sort(modList.begin(), modList.end(), [](Mod::Ptr a, Mod::Ptr b) { std::sort(modList.begin(), modList.end(), [](auto a, auto b) {
auto aName = a->fileinfo().completeBaseName(); auto aName = a->fileinfo().completeBaseName();
auto bName = b->fileinfo().completeBaseName(); auto bName = b->fileinfo().completeBaseName();
return aName.localeAwareCompare(bName) < 0; return aName.localeAwareCompare(bName) < 0;

View File

@ -251,7 +251,7 @@ bool ResourceFolderModel::update()
return true; return true;
} }
void ResourceFolderModel::resolveResource(Resource::Ptr res) void ResourceFolderModel::resolveResource(Resource* res)
{ {
if (!res->shouldResolve()) { if (!res->shouldResolve()) {
return; return;

View File

@ -68,7 +68,7 @@ class ResourceFolderModel : public QAbstractListModel {
virtual bool update(); virtual bool update();
/** Creates a new parse task, if needed, for 'res' and start it.*/ /** Creates a new parse task, if needed, for 'res' and start it.*/
virtual void resolveResource(Resource::Ptr res); virtual void resolveResource(Resource* res);
[[nodiscard]] size_t size() const { return m_resources.size(); }; [[nodiscard]] size_t size() const { return m_resources.size(); };
[[nodiscard]] bool empty() const { return size() == 0; } [[nodiscard]] bool empty() const { return size() == 0; }
@ -265,7 +265,7 @@ void ResourceFolderModel::applyUpdates(QSet<QString>& current_set, QSet<QString>
} }
m_resources[row].reset(new_resource); m_resources[row].reset(new_resource);
resolveResource(m_resources.at(row)); resolveResource(m_resources[row].get());
emit dataChanged(index(row, 0), index(row, columnCount(QModelIndex()) - 1)); emit dataChanged(index(row, 0), index(row, columnCount(QModelIndex()) - 1));
} }
} }
@ -313,7 +313,7 @@ void ResourceFolderModel::applyUpdates(QSet<QString>& current_set, QSet<QString>
for (auto& added : added_set) { for (auto& added : added_set) {
auto res = new_resources[added]; auto res = new_resources[added];
m_resources.append(res); m_resources.append(res);
resolveResource(res); resolveResource(m_resources.last().get());
} }
endInsertRows(); endInsertRows();

View File

@ -99,7 +99,7 @@ void ModFolderLoadTask::executeTask()
// Remove orphan metadata to prevent issues // Remove orphan metadata to prevent issues
// See https://github.com/PolyMC/PolyMC/issues/996 // See https://github.com/PolyMC/PolyMC/issues/996
if (m_clean_orphan) { if (m_clean_orphan) {
QMutableMapIterator<QString, Mod::Ptr> iter(m_result->mods); QMutableMapIterator iter(m_result->mods);
while (iter.hasNext()) { while (iter.hasNext()) {
auto mod = iter.next().value(); auto mod = iter.next().value();
if (mod->status() == ModStatus::NotInstalled) { if (mod->status() == ModStatus::NotInstalled) {