fix: raw-pointers and leaks in ModFolderLoadTask

Co-authored-by: timoreo <contact@timoreo.fr>
Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
flow 2022-07-17 11:56:23 -03:00
parent 6bb8332b4b
commit 54b335711a
No known key found for this signature in database
GPG Key ID: 8D0F221F0A59F469
3 changed files with 3 additions and 4 deletions

View File

@ -143,7 +143,7 @@ void ModFolderModel::finishUpdate()
QSet<QString> 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()) {

View File

@ -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())) {

View File

@ -48,7 +48,7 @@ class ModFolderLoadTask : public QObject, public QRunnable
Q_OBJECT
public:
struct Result {
QMap<QString, Mod*> mods;
QMap<QString, Mod::Ptr> mods;
};
using ResultPtr = std::shared_ptr<Result>;
ResultPtr result() const {