From 54b335711acac5e57e94bc9cb81c751c9b2872c5 Mon Sep 17 00:00:00 2001 From: flow Date: Sun, 17 Jul 2022 11:56:23 -0300 Subject: [PATCH] fix: raw-pointers and leaks in ModFolderLoadTask Co-authored-by: timoreo Signed-off-by: flow --- launcher/minecraft/mod/ModFolderModel.cpp | 2 +- launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp | 3 +-- launcher/minecraft/mod/tasks/ModFolderLoadTask.h | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/launcher/minecraft/mod/ModFolderModel.cpp b/launcher/minecraft/mod/ModFolderModel.cpp index c4449b2a..112d219e 100644 --- a/launcher/minecraft/mod/ModFolderModel.cpp +++ b/launcher/minecraft/mod/ModFolderModel.cpp @@ -143,7 +143,7 @@ void ModFolderModel::finishUpdate() QSet kept = currentSet; kept.intersect(newSet); for(auto& keptMod : kept) { - auto* newMod = newMods[keptMod]; + auto newMod = newMods[keptMod]; auto row = modsIndex[keptMod]; auto currentMod = mods[row]; if(newMod->dateTimeChanged() == currentMod->dateTimeChanged()) { diff --git a/launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp b/launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp index 63a6ca90..a2e055ba 100644 --- a/launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp +++ b/launcher/minecraft/mod/tasks/ModFolderLoadTask.cpp @@ -36,7 +36,6 @@ #include "ModFolderLoadTask.h" -#include "Application.h" #include "minecraft/mod/MetadataHandler.h" ModFolderLoadTask::ModFolderLoadTask(QDir& mods_dir, QDir& index_dir, bool is_indexed) @@ -53,7 +52,7 @@ void ModFolderLoadTask::run() // Read JAR files that don't have metadata m_mods_dir.refresh(); for (auto entry : m_mods_dir.entryInfoList()) { - auto* mod = new Mod(entry); + Mod::Ptr mod(new Mod(entry)); if (mod->enabled()) { if (m_result->mods.contains(mod->internal_id())) { diff --git a/launcher/minecraft/mod/tasks/ModFolderLoadTask.h b/launcher/minecraft/mod/tasks/ModFolderLoadTask.h index 7568fdf5..0b6bb6cc 100644 --- a/launcher/minecraft/mod/tasks/ModFolderLoadTask.h +++ b/launcher/minecraft/mod/tasks/ModFolderLoadTask.h @@ -48,7 +48,7 @@ class ModFolderLoadTask : public QObject, public QRunnable Q_OBJECT public: struct Result { - QMap mods; + QMap mods; }; using ResultPtr = std::shared_ptr; ResultPtr result() const {