diff options
author | Petr Mrázek <peterix@gmail.com> | 2014-03-30 20:11:05 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2014-03-30 20:11:41 +0200 |
commit | fbc29b6a0626f2ce8521dc74e3171b634d68e9e5 (patch) | |
tree | d2d79201be585131be2ab0cd7d337237887af5a0 /logic/lists | |
parent | e1e1d99102936b419aac52974f1fdb8be835b0d4 (diff) | |
download | MultiMC-fbc29b6a0626f2ce8521dc74e3171b634d68e9e5.tar MultiMC-fbc29b6a0626f2ce8521dc74e3171b634d68e9e5.tar.gz MultiMC-fbc29b6a0626f2ce8521dc74e3171b634d68e9e5.tar.lz MultiMC-fbc29b6a0626f2ce8521dc74e3171b634d68e9e5.tar.xz MultiMC-fbc29b6a0626f2ce8521dc74e3171b634d68e9e5.zip |
Fix many memory leaks.
Diffstat (limited to 'logic/lists')
-rw-r--r-- | logic/lists/InstanceList.cpp | 14 | ||||
-rw-r--r-- | logic/lists/InstanceList.h | 5 |
2 files changed, 12 insertions, 7 deletions
diff --git a/logic/lists/InstanceList.cpp b/logic/lists/InstanceList.cpp index 34e6d87b..1ff0d2ec 100644 --- a/logic/lists/InstanceList.cpp +++ b/logic/lists/InstanceList.cpp @@ -90,6 +90,10 @@ QVariant InstanceList::data(const QModelIndex &index, int role) const QVariant v = qVariantFromValue((void *)pdata); return v; } + case InstanceIDRole: + { + return pdata->id(); + } case Qt::DisplayRole: { return pdata->name(); @@ -378,7 +382,7 @@ void InstanceList::loadFTBInstances(QMap<QString, QString> &groupMap, if (!QFileInfo(PathCombine(record.instanceDir, "instance.cfg")).exists()) { QLOG_INFO() << "Converting " << record.name << " as new."; - BaseInstance *instPtr = NULL; + InstancePtr instPtr; auto &factory = InstanceFactory::get(); auto version = MMC->minecraftlist()->findVersion(record.mcVersion); if (!version) @@ -406,7 +410,7 @@ void InstanceList::loadFTBInstances(QMap<QString, QString> &groupMap, else { QLOG_INFO() << "Loading existing " << record.name; - BaseInstance *instPtr = NULL; + InstancePtr instPtr; auto error = InstanceFactory::get().loadInstance(instPtr, record.instanceDir); if (!instPtr || error != InstanceFactory::NoLoadError) continue; @@ -439,11 +443,11 @@ InstanceList::InstListError InstanceList::loadList() if (!QFileInfo(PathCombine(subDir, "instance.cfg")).exists()) continue; QLOG_INFO() << "Loading MultiMC instance from " << subDir; - BaseInstance *instPtr = NULL; + InstancePtr instPtr; auto error = InstanceFactory::get().loadInstance(instPtr, subDir); if(!continueProcessInstance(instPtr, error, subDir, groupMap)) continue; - tempList.append(InstancePtr(instPtr)); + tempList.append(instPtr); } } @@ -536,7 +540,7 @@ int InstanceList::getInstIndex(BaseInstance *inst) const return -1; } -bool InstanceList::continueProcessInstance(BaseInstance *instPtr, const int error, +bool InstanceList::continueProcessInstance(InstancePtr instPtr, const int error, const QDir &dir, QMap<QString, QString> &groupMap) { if (error != InstanceFactory::NoLoadError && error != InstanceFactory::NotAnInstance) diff --git a/logic/lists/InstanceList.h b/logic/lists/InstanceList.h index ebe3e051..f0bbb7ec 100644 --- a/logic/lists/InstanceList.h +++ b/logic/lists/InstanceList.h @@ -62,7 +62,8 @@ public: enum AdditionalRoles { - InstancePointerRole = 0x34B1CB48 ///< Return pointer to real instance + InstancePointerRole = 0x34B1CB48, ///< Return pointer to real instance + InstanceIDRole = 0x34B1CB49 ///< Return id if the instance }; /*! * \brief Error codes returned by functions in the InstanceList class. @@ -132,7 +133,7 @@ slots: private: int getInstIndex(BaseInstance *inst) const; - bool continueProcessInstance(BaseInstance *instPtr, const int error, const QDir &dir, + bool continueProcessInstance(InstancePtr instPtr, const int error, const QDir &dir, QMap<QString, QString> &groupMap); protected: |