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 | |
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.
35 files changed, 139 insertions, 103 deletions
diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index 60b64cb9..480ee3b1 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -269,27 +269,32 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi auto accounts = MMC->accounts(); - // TODO: Nicer way to iterate? + QList<CacheDownloadPtr> skin_dls; for (int i = 0; i < accounts->count(); i++) { auto account = accounts->at(i); if (account != nullptr) { - auto job = new NetJob("Startup player skins: " + account->username()); - for (auto profile : account->profiles()) { auto meta = MMC->metacache()->resolveEntry("skins", profile.name + ".png"); auto action = CacheDownload::make( QUrl("http://" + URLConstants::SKINS_BASE + profile.name + ".png"), meta); - job->addNetAction(action); + skin_dls.append(action); meta->stale = true; } - - connect(job, SIGNAL(succeeded()), SLOT(activeAccountChanged())); - job->start(); } } + if(!skin_dls.isEmpty()) + { + auto job = new NetJob("Startup player skins download"); + connect(job, SIGNAL(succeeded()), SLOT(skinJobFinished())); + connect(job, SIGNAL(failed()), SLOT(skinJobFinished())); + for(auto action: skin_dls) + job->addNetAction(action); + skin_download_job.reset(job); + job->start(); + } // run the things that load and download other things... FIXME: this is NOT the place // FIXME: invisible actions in the background = NOPE. @@ -338,6 +343,13 @@ MainWindow::~MainWindow() delete proxymodel; } +void MainWindow::skinJobFinished() +{ + activeAccountChanged(); + skin_download_job.reset(); +} + + void MainWindow::showInstanceContextMenu(const QPoint &pos) { if (!view->indexAt(pos).isValid()) @@ -748,7 +760,7 @@ void MainWindow::on_actionAddInstance_triggered() if (!newInstDlg.exec()) return; - BaseInstance *newInstance = NULL; + InstancePtr newInstance; QString instancesDir = MMC->settings()->get("InstanceDir").toString(); QString instDirName = DirNameFromString(newInstDlg.instName(), instancesDir); @@ -825,7 +837,7 @@ void MainWindow::on_actionCopyInstance_triggered() auto &loader = InstanceFactory::get(); - BaseInstance *newInstance = NULL; + InstancePtr newInstance; auto error = loader.copyInstance(newInstance, m_selectedInstance, instDir); QString errorMsg = tr("Failed to create instance %1: ").arg(instDirName); @@ -834,7 +846,7 @@ void MainWindow::on_actionCopyInstance_triggered() case InstanceFactory::NoCreateError: newInstance->setName(copyInstDlg.instName()); newInstance->setIconKey(copyInstDlg.iconKey()); - MMC->instances()->add(InstancePtr(newInstance)); + MMC->instances()->add(newInstance); return; case InstanceFactory::InstExists: @@ -1084,9 +1096,10 @@ void MainWindow::instanceActivated(QModelIndex index) { if (!index.isValid()) return; - - BaseInstance *inst = - (BaseInstance *)index.data(InstanceList::InstancePointerRole).value<void *>(); + QString id = index.data(InstanceList::InstanceIDRole).toString(); + InstancePtr inst = MMC->instances()->getInstanceById(id); + if(!inst) + return; NagUtils::checkJVMArgs(inst->settings().get("JvmArgs").toString(), this); @@ -1239,7 +1252,7 @@ void MainWindow::doLaunch(bool online, BaseProfilerFactory *profiler) } } -void MainWindow::updateInstance(BaseInstance *instance, AuthSessionPtr session, BaseProfilerFactory *profiler) +void MainWindow::updateInstance(InstancePtr instance, AuthSessionPtr session, BaseProfilerFactory *profiler) { auto updateTask = instance->doUpdate(); if (!updateTask) @@ -1254,7 +1267,7 @@ void MainWindow::updateInstance(BaseInstance *instance, AuthSessionPtr session, tDialog.exec(updateTask.get()); } -void MainWindow::launchInstance(BaseInstance *instance, AuthSessionPtr session, BaseProfilerFactory *profiler) +void MainWindow::launchInstance(InstancePtr instance, AuthSessionPtr session, BaseProfilerFactory *profiler) { Q_ASSERT_X(instance != NULL, "launchInstance", "instance is NULL"); Q_ASSERT_X(session.get() != nullptr, "launchInstance", "session is NULL"); @@ -1427,8 +1440,9 @@ void MainWindow::on_actionChangeInstLWJGLVersion_triggered() lselect.exec(); if (lselect.result() == QDialog::Accepted) { - LegacyInstance *linst = (LegacyInstance *)m_selectedInstance; - linst->setLWJGLVersion(lselect.selectedVersion()); + auto ptr = std::dynamic_pointer_cast<LegacyInstance>(m_selectedInstance); + if(ptr) + ptr->setLWJGLVersion(lselect.selectedVersion()); } } @@ -1444,10 +1458,15 @@ void MainWindow::on_actionInstanceSettings_triggered() void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex &previous) { - if (current.isValid() && - nullptr != (m_selectedInstance = - (BaseInstance *)current.data(InstanceList::InstancePointerRole) - .value<void *>())) + if(!current.isValid()) + { + selectionBad(); + MMC->settings()->set("SelectedInstance", QString()); + return; + } + QString id = current.data(InstanceList::InstanceIDRole).toString(); + m_selectedInstance = MMC->instances()->getInstanceById(id); + if ( m_selectedInstance ) { ui->instanceToolBar->setEnabled(m_selectedInstance->canLaunch()); renameButton->setText(m_selectedInstance->name()); @@ -1466,9 +1485,9 @@ void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex & } else { - selectionBad(); - - MMC->settings()->set("SelectedInstance", QString()); + selectionBad(); + MMC->settings()->set("SelectedInstance", QString()); + return; } } @@ -1490,14 +1509,13 @@ void MainWindow::on_actionEditInstNotes_triggered() { if (!m_selectedInstance) return; - LegacyInstance *linst = (LegacyInstance *)m_selectedInstance; - EditNotesDialog noteedit(linst->notes(), linst->name(), this); + EditNotesDialog noteedit(m_selectedInstance->notes(), m_selectedInstance->name(), this); noteedit.exec(); if (noteedit.result() == QDialog::Accepted) { - linst->setNotes(noteedit.getText()); + m_selectedInstance->setNotes(noteedit.getText()); } } diff --git a/gui/MainWindow.h b/gui/MainWindow.h index 3a2843f8..5ddfef7b 100644 --- a/gui/MainWindow.h +++ b/gui/MainWindow.h @@ -23,6 +23,7 @@ #include "logic/BaseInstance.h" #include "logic/auth/MojangAccount.h" +#include <logic/net/NetJob.h> class QToolButton; class LabeledToolButton; @@ -118,12 +119,12 @@ slots: * Launches the given instance with the given account. * This function assumes that the given account has a valid, usable access token. */ - void launchInstance(BaseInstance *instance, AuthSessionPtr session, BaseProfilerFactory *profiler = 0); + void launchInstance(InstancePtr instance, AuthSessionPtr session, BaseProfilerFactory *profiler = 0); /*! * Prepares the given instance for launch with the given account. */ - void updateInstance(BaseInstance *instance, AuthSessionPtr account, BaseProfilerFactory *profiler = 0); + void updateInstance(InstancePtr instance, AuthSessionPtr account, BaseProfilerFactory *profiler = 0); void onGameUpdateError(QString error); @@ -145,6 +146,7 @@ slots: void updateToolsMenu(); + void skinJobFinished(); public slots: void instanceActivated(QModelIndex); @@ -189,13 +191,14 @@ private: Ui::MainWindow *ui; class GroupView *view; InstanceProxyModel *proxymodel; + NetJobPtr skin_download_job; MinecraftProcess *proc; ConsoleWindow *console; LabeledToolButton *renameButton; QToolButton *changeIconButton; QToolButton *newsLabel; - BaseInstance *m_selectedInstance; + InstancePtr m_selectedInstance; QString m_currentInstIcon; Task *m_versionLoadTask; diff --git a/gui/dialogs/CopyInstanceDialog.cpp b/gui/dialogs/CopyInstanceDialog.cpp index 4095408b..71429367 100644 --- a/gui/dialogs/CopyInstanceDialog.cpp +++ b/gui/dialogs/CopyInstanceDialog.cpp @@ -32,7 +32,7 @@ #include "logic/tasks/Task.h" #include "logic/BaseInstance.h" -CopyInstanceDialog::CopyInstanceDialog(BaseInstance *original, QWidget *parent) +CopyInstanceDialog::CopyInstanceDialog(InstancePtr original, QWidget *parent) :QDialog(parent), ui(new Ui::CopyInstanceDialog), m_original(original) { MultiMCPlatform::fixWM_CLASS(this); diff --git a/gui/dialogs/CopyInstanceDialog.h b/gui/dialogs/CopyInstanceDialog.h index 7ab366e2..95f4bf6c 100644 --- a/gui/dialogs/CopyInstanceDialog.h +++ b/gui/dialogs/CopyInstanceDialog.h @@ -17,6 +17,7 @@ #include <QDialog> #include "logic/BaseVersion.h" +#include <logic/BaseInstance.h> class BaseInstance; @@ -30,7 +31,7 @@ class CopyInstanceDialog : public QDialog Q_OBJECT public: - explicit CopyInstanceDialog(BaseInstance *original, QWidget *parent = 0); + explicit CopyInstanceDialog(InstancePtr original, QWidget *parent = 0); ~CopyInstanceDialog(); void updateDialogState(); @@ -46,5 +47,5 @@ slots: private: Ui::CopyInstanceDialog *ui; QString InstIconKey; - BaseInstance *m_original; + InstancePtr m_original; }; diff --git a/gui/groupview/InstanceDelegate.cpp b/gui/groupview/InstanceDelegate.cpp index 7ca4d7b4..cd26ddaa 100644 --- a/gui/groupview/InstanceDelegate.cpp +++ b/gui/groupview/InstanceDelegate.cpp @@ -317,6 +317,7 @@ void ListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti line.draw(painter, position); } + // FIXME: this really has no business of being here. Make generic. auto instance = (BaseInstance*)index.data(InstanceList::InstancePointerRole) .value<void *>(); if (instance) diff --git a/logic/BaseInstance_p.h b/logic/BaseInstance_p.h index edaee7d7..999ff545 100644 --- a/logic/BaseInstance_p.h +++ b/logic/BaseInstance_p.h @@ -24,8 +24,10 @@ #define I_D(Class) Class##Private *const d = (Class##Private * const)inst_d.get() -struct BaseInstancePrivate +class BaseInstancePrivate { +public: + virtual ~BaseInstancePrivate(){}; QString m_rootDir; QString m_group; std::shared_ptr<SettingsObject> m_settings; diff --git a/logic/InstanceFactory.cpp b/logic/InstanceFactory.cpp index d6e06133..4f65221c 100644 --- a/logic/InstanceFactory.cpp +++ b/logic/InstanceFactory.cpp @@ -41,7 +41,7 @@ InstanceFactory::InstanceFactory() : QObject(NULL) { } -InstanceFactory::InstLoadError InstanceFactory::loadInstance(BaseInstance *&inst, +InstanceFactory::InstLoadError InstanceFactory::loadInstance(InstancePtr &inst, const QString &instDir) { auto m_settings = new INISettingsObject(PathCombine(instDir, "instance.cfg")); @@ -53,23 +53,23 @@ InstanceFactory::InstLoadError InstanceFactory::loadInstance(BaseInstance *&inst // FIXME: replace with a map lookup, where instance classes register their types if (inst_type == "OneSix") { - inst = new OneSixInstance(instDir, m_settings, this); + inst.reset(new OneSixInstance(instDir, m_settings, this)); } else if (inst_type == "Legacy") { - inst = new LegacyInstance(instDir, m_settings, this); + inst.reset(new LegacyInstance(instDir, m_settings, this)); } else if (inst_type == "Nostalgia") { - inst = new NostalgiaInstance(instDir, m_settings, this); + inst.reset(new NostalgiaInstance(instDir, m_settings, this)); } else if (inst_type == "LegacyFTB") { - inst = new LegacyFTBInstance(instDir, m_settings, this); + inst.reset(new LegacyFTBInstance(instDir, m_settings, this)); } else if (inst_type == "OneSixFTB") { - inst = new OneSixFTBInstance(instDir, m_settings, this); + inst.reset(new OneSixFTBInstance(instDir, m_settings, this)); } else { @@ -79,10 +79,8 @@ InstanceFactory::InstLoadError InstanceFactory::loadInstance(BaseInstance *&inst return NoLoadError; } -InstanceFactory::InstCreateError InstanceFactory::createInstance(BaseInstance *&inst, - BaseVersionPtr version, - const QString &instDir, - const InstType type) +InstanceFactory::InstCreateError InstanceFactory::createInstance(InstancePtr &inst, BaseVersionPtr version, + const QString &instDir, const InstanceFactory::InstType type) { QDir rootDir(instDir); @@ -105,19 +103,19 @@ InstanceFactory::InstCreateError InstanceFactory::createInstance(BaseInstance *& case MinecraftVersion::Legacy: // TODO new instance type m_settings->set("InstanceType", "Legacy"); - inst = new LegacyInstance(instDir, m_settings, this); + inst.reset(new LegacyInstance(instDir, m_settings, this)); inst->setIntendedVersionId(version->descriptor()); inst->setShouldUseCustomBaseJar(false); break; case MinecraftVersion::OneSix: m_settings->set("InstanceType", "OneSix"); - inst = new OneSixInstance(instDir, m_settings, this); + inst.reset(new OneSixInstance(instDir, m_settings, this)); inst->setIntendedVersionId(version->descriptor()); inst->setShouldUseCustomBaseJar(false); break; case MinecraftVersion::Nostalgia: m_settings->set("InstanceType", "Nostalgia"); - inst = new NostalgiaInstance(instDir, m_settings, this); + inst.reset(new NostalgiaInstance(instDir, m_settings, this)); inst->setIntendedVersionId(version->descriptor()); inst->setShouldUseCustomBaseJar(false); break; @@ -134,13 +132,13 @@ InstanceFactory::InstCreateError InstanceFactory::createInstance(BaseInstance *& { case MinecraftVersion::Legacy: m_settings->set("InstanceType", "LegacyFTB"); - inst = new LegacyFTBInstance(instDir, m_settings, this); + inst.reset(new LegacyFTBInstance(instDir, m_settings, this)); inst->setIntendedVersionId(version->descriptor()); inst->setShouldUseCustomBaseJar(false); break; case MinecraftVersion::OneSix: m_settings->set("InstanceType", "OneSixFTB"); - inst = new OneSixFTBInstance(instDir, m_settings, this); + inst.reset(new OneSixFTBInstance(instDir, m_settings, this)); inst->setIntendedVersionId(version->descriptor()); inst->setShouldUseCustomBaseJar(false); break; @@ -163,8 +161,8 @@ InstanceFactory::InstCreateError InstanceFactory::createInstance(BaseInstance *& return InstanceFactory::NoCreateError; } -InstanceFactory::InstCreateError InstanceFactory::copyInstance(BaseInstance *&newInstance, - BaseInstance *&oldInstance, +InstanceFactory::InstCreateError InstanceFactory::copyInstance(InstancePtr &newInstance, + InstancePtr &oldInstance, const QString &instDir) { QDir rootDir(instDir); @@ -175,14 +173,6 @@ InstanceFactory::InstCreateError InstanceFactory::copyInstance(BaseInstance *&ne rootDir.removeRecursively(); return InstanceFactory::CantCreateDir; } - auto m_settings = new INISettingsObject(PathCombine(instDir, "instance.cfg")); - m_settings->registerSetting("InstanceType", "Legacy"); - QString inst_type = m_settings->get("InstanceType").toString(); - - if(inst_type == "OneSixFTB") - m_settings->set("InstanceType", "OneSix"); - if(inst_type == "LegacyFTB") - m_settings->set("InstanceType", "Legacy"); oldInstance->copy(instDir); @@ -198,6 +188,7 @@ InstanceFactory::InstCreateError InstanceFactory::copyInstance(BaseInstance *&ne default: case UnknownLoadError: rootDir.removeRecursively(); - return UnknownCreateError; + return UnknownCreateError; } + return UnknownCreateError; } diff --git a/logic/InstanceFactory.h b/logic/InstanceFactory.h index 5ff4c7ec..96e2375e 100644 --- a/logic/InstanceFactory.h +++ b/logic/InstanceFactory.h @@ -20,6 +20,7 @@ #include <QList> #include "BaseVersion.h" +#include "BaseInstance.h" class BaseVersion; class BaseInstance; @@ -72,7 +73,7 @@ public: * - InstExists if the given instance directory is already an instance. * - CantCreateDir if the given instance directory cannot be created. */ - InstCreateError createInstance(BaseInstance *&inst, BaseVersionPtr version, + InstCreateError createInstance(InstancePtr &inst, BaseVersionPtr version, const QString &instDir, const InstType type = NormalInst); /*! @@ -85,7 +86,7 @@ public: * - InstExists if the given instance directory is already an instance. * - CantCreateDir if the given instance directory cannot be created. */ - InstCreateError copyInstance(BaseInstance *&newInstance, BaseInstance *&oldInstance, + InstCreateError copyInstance(InstancePtr &newInstance, InstancePtr &oldInstance, const QString &instDir); /*! @@ -96,7 +97,7 @@ public: * \return An InstLoadError error code. * - NotAnInstance if the given instance directory isn't a valid instance. */ - InstLoadError loadInstance(BaseInstance *&inst, const QString &instDir); + InstLoadError loadInstance(InstancePtr &inst, const QString &instDir); private: InstanceFactory(); diff --git a/logic/LegacyInstance_p.h b/logic/LegacyInstance_p.h index ed97ccd3..061847de 100644 --- a/logic/LegacyInstance_p.h +++ b/logic/LegacyInstance_p.h @@ -21,8 +21,10 @@ #include "BaseInstance_p.h" #include "ModList.h" -struct LegacyInstancePrivate : public BaseInstancePrivate +class LegacyInstancePrivate : public BaseInstancePrivate { +public: + virtual ~LegacyInstancePrivate() {}; std::shared_ptr<ModList> jar_mod_list; std::shared_ptr<ModList> core_mod_list; std::shared_ptr<ModList> loader_mod_list; diff --git a/logic/NostalgiaInstance.h b/logic/NostalgiaInstance.h index a26f7f0a..f95531d2 100644 --- a/logic/NostalgiaInstance.h +++ b/logic/NostalgiaInstance.h @@ -23,6 +23,7 @@ class NostalgiaInstance : public OneSixInstance public: explicit NostalgiaInstance(const QString &rootDir, SettingsObject *settings, QObject *parent = 0); + virtual ~NostalgiaInstance() {}; virtual QString getStatusbarDescription(); virtual bool menuActionEnabled(QString action_name) const; }; diff --git a/logic/OneSixFTBInstance.h b/logic/OneSixFTBInstance.h index c4f845e0..440dc9f1 100644 --- a/logic/OneSixFTBInstance.h +++ b/logic/OneSixFTBInstance.h @@ -10,6 +10,7 @@ class OneSixFTBInstance : public OneSixInstance public: explicit OneSixFTBInstance(const QString &rootDir, SettingsObject *settings, QObject *parent = 0); + virtual ~OneSixFTBInstance(){}; void init() override; void copy(const QDir &newDir) override; diff --git a/logic/OneSixInstance.h b/logic/OneSixInstance.h index 7a049922..677459ae 100644 --- a/logic/OneSixInstance.h +++ b/logic/OneSixInstance.h @@ -26,6 +26,7 @@ class OneSixInstance : public BaseInstance public: explicit OneSixInstance(const QString &rootDir, SettingsObject *settings, QObject *parent = 0); + virtual ~OneSixInstance(){}; virtual void init() override; diff --git a/logic/OneSixInstance_p.h b/logic/OneSixInstance_p.h index 2dffa62c..c70de07c 100644 --- a/logic/OneSixInstance_p.h +++ b/logic/OneSixInstance_p.h @@ -19,8 +19,10 @@ #include "VersionFinal.h" #include "ModList.h" -struct OneSixInstancePrivate : public BaseInstancePrivate +class OneSixInstancePrivate : public BaseInstancePrivate { +public: + virtual ~OneSixInstancePrivate() {}; std::shared_ptr<VersionFinal> version; std::shared_ptr<VersionFinal> vanillaVersion; std::shared_ptr<ModList> loader_mod_list; 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: diff --git a/logic/net/ByteArrayDownload.h b/logic/net/ByteArrayDownload.h index 0d90abc2..76e2e279 100644 --- a/logic/net/ByteArrayDownload.h +++ b/logic/net/ByteArrayDownload.h @@ -26,7 +26,7 @@ public: { return ByteArrayDownloadPtr(new ByteArrayDownload(url)); } - + virtual ~ByteArrayDownload() {}; public: /// if not saving to file, downloaded data is placed here QByteArray m_data; diff --git a/logic/net/CacheDownload.h b/logic/net/CacheDownload.h index 154f5988..d446d23e 100644 --- a/logic/net/CacheDownload.h +++ b/logic/net/CacheDownload.h @@ -41,6 +41,7 @@ public: { return CacheDownloadPtr(new CacheDownload(url, entry)); } + virtual ~CacheDownload(){}; QString getTargetFilepath() { return m_target_path; diff --git a/logic/net/ForgeMirrors.h b/logic/net/ForgeMirrors.h index 990e49d6..6784fba1 100644 --- a/logic/net/ForgeMirrors.h +++ b/logic/net/ForgeMirrors.h @@ -39,7 +39,7 @@ public: { return ForgeMirrorsPtr(new ForgeMirrors(libs, parent_job, mirrorlist)); } - + virtual ~ForgeMirrors(){}; protected slots: virtual void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); diff --git a/logic/net/ForgeXzDownload.h b/logic/net/ForgeXzDownload.h index 990f91f0..7bdfb6d9 100644 --- a/logic/net/ForgeXzDownload.h +++ b/logic/net/ForgeXzDownload.h @@ -45,6 +45,7 @@ public: { return ForgeXzDownloadPtr(new ForgeXzDownload(relative_path, entry)); } + virtual ~ForgeXzDownload(){}; void setMirrors(QList<ForgeMirror> & mirrors); protected diff --git a/logic/net/MD5EtagDownload.h b/logic/net/MD5EtagDownload.h index d5aed0ca..f5031e46 100644 --- a/logic/net/MD5EtagDownload.h +++ b/logic/net/MD5EtagDownload.h @@ -38,6 +38,7 @@ public: { return Md5EtagDownloadPtr(new MD5EtagDownload(url, target_path)); } + virtual ~MD5EtagDownload(){}; protected slots: virtual void downloadProgress(qint64 bytesReceived, qint64 bytesTotal); diff --git a/logic/net/NetJob.h b/logic/net/NetJob.h index 03d6a36e..2df8428b 100644 --- a/logic/net/NetJob.h +++ b/logic/net/NetJob.h @@ -32,7 +32,7 @@ class NetJob : public ProgressProvider Q_OBJECT public: explicit NetJob(QString job_name) : ProgressProvider(), m_job_name(job_name) {}; - + virtual ~NetJob() {}; template <typename T> bool addNetAction(T action) { NetActionPtr base = std::static_pointer_cast<NetAction>(action); diff --git a/logic/net/PasteUpload.h b/logic/net/PasteUpload.h index 83876c17..55cfabf4 100644 --- a/logic/net/PasteUpload.h +++ b/logic/net/PasteUpload.h @@ -9,6 +9,7 @@ class PasteUpload : public Task Q_OBJECT public: PasteUpload(QWidget *window, QString text); + virtual ~PasteUpload(){}; protected: virtual void executeTask(); diff --git a/logic/screenshots/ScreenshotList.cpp b/logic/screenshots/ScreenshotList.cpp index 8a64dc36..a34f4d46 100644 --- a/logic/screenshots/ScreenshotList.cpp +++ b/logic/screenshots/ScreenshotList.cpp @@ -7,7 +7,7 @@ #include "gui/dialogs/ProgressDialog.h" #include "gui/dialogs/CustomMessageBox.h" -ScreenshotList::ScreenshotList(BaseInstance *instance, QObject *parent) +ScreenshotList::ScreenshotList(InstancePtr instance, QObject *parent) : QAbstractListModel(parent), m_instance(instance) { } diff --git a/logic/screenshots/ScreenshotList.h b/logic/screenshots/ScreenshotList.h index ca6314e9..dc26a698 100644 --- a/logic/screenshots/ScreenshotList.h +++ b/logic/screenshots/ScreenshotList.h @@ -10,7 +10,7 @@ class ScreenshotList : public QAbstractListModel { Q_OBJECT public: - ScreenshotList(BaseInstance *instance, QObject *parent = 0); + ScreenshotList(InstancePtr instance, QObject *parent = 0); QVariant data(const QModelIndex &index, int role) const; QVariant headerData(int section, Qt::Orientation orientation, int role) const; @@ -31,7 +31,7 @@ public: return m_screenshots; } - BaseInstance *instance() const + InstancePtr instance() const { return m_instance; } @@ -45,7 +45,7 @@ slots: private: QList<ScreenshotPtr> m_screenshots; - BaseInstance *m_instance; + InstancePtr m_instance; }; class ScreenshotLoadTask : public Task diff --git a/logic/tasks/Task.h b/logic/tasks/Task.h index 84775407..063eeeda 100644 --- a/logic/tasks/Task.h +++ b/logic/tasks/Task.h @@ -24,6 +24,7 @@ class Task : public ProgressProvider Q_OBJECT public: explicit Task(QObject *parent = 0); + virtual ~Task() {}; virtual QString getStatus() const; virtual void getProgress(qint64 ¤t, qint64 &total); diff --git a/logic/tools/BaseExternalTool.cpp b/logic/tools/BaseExternalTool.cpp index 69cddd00..23f154e2 100644 --- a/logic/tools/BaseExternalTool.cpp +++ b/logic/tools/BaseExternalTool.cpp @@ -11,7 +11,7 @@ #include "logic/BaseInstance.h" #include "MultiMC.h" -BaseExternalTool::BaseExternalTool(BaseInstance *instance, QObject *parent) +BaseExternalTool::BaseExternalTool(InstancePtr instance, QObject *parent) : QObject(parent), m_instance(instance) { } @@ -55,7 +55,7 @@ QString BaseExternalTool::getSave() const } -BaseDetachedTool::BaseDetachedTool(BaseInstance *instance, QObject *parent) +BaseDetachedTool::BaseDetachedTool(InstancePtr instance, QObject *parent) : BaseExternalTool(instance, parent) { @@ -71,7 +71,8 @@ BaseExternalToolFactory::~BaseExternalToolFactory() { } -BaseDetachedTool *BaseDetachedToolFactory::createDetachedTool(BaseInstance *instance, QObject *parent) +BaseDetachedTool *BaseDetachedToolFactory::createDetachedTool(InstancePtr instance, + QObject *parent) { return qobject_cast<BaseDetachedTool *>(createTool(instance, parent)); } diff --git a/logic/tools/BaseExternalTool.h b/logic/tools/BaseExternalTool.h index e8965bfd..7672bf10 100644 --- a/logic/tools/BaseExternalTool.h +++ b/logic/tools/BaseExternalTool.h @@ -1,6 +1,7 @@ #pragma once #include <QObject> +#include <logic/BaseInstance.h> class BaseInstance; class SettingsObject; @@ -11,11 +12,11 @@ class BaseExternalTool : public QObject { Q_OBJECT public: - explicit BaseExternalTool(BaseInstance *instance, QObject *parent = 0); + explicit BaseExternalTool(InstancePtr instance, QObject *parent = 0); virtual ~BaseExternalTool(); protected: - BaseInstance *m_instance; + InstancePtr m_instance; qint64 pid(QProcess *process); QString getSave() const; @@ -25,7 +26,7 @@ class BaseDetachedTool : public BaseExternalTool { Q_OBJECT public: - explicit BaseDetachedTool(BaseInstance *instance, QObject *parent = 0); + explicit BaseDetachedTool(InstancePtr instance, QObject *parent = 0); public slots: @@ -44,7 +45,7 @@ public: virtual void registerSettings(SettingsObject *settings) = 0; - virtual BaseExternalTool *createTool(BaseInstance *instance, QObject *parent = 0) = 0; + virtual BaseExternalTool *createTool(InstancePtr instance, QObject *parent = 0) = 0; virtual bool check(QString *error) = 0; virtual bool check(const QString &path, QString *error) = 0; @@ -53,5 +54,5 @@ public: class BaseDetachedToolFactory : public BaseExternalToolFactory { public: - virtual BaseDetachedTool *createDetachedTool(BaseInstance *instance, QObject *parent = 0); + virtual BaseDetachedTool *createDetachedTool(InstancePtr instance, QObject *parent = 0); }; diff --git a/logic/tools/BaseProfiler.cpp b/logic/tools/BaseProfiler.cpp index 9aaca793..7cd1c5c7 100644 --- a/logic/tools/BaseProfiler.cpp +++ b/logic/tools/BaseProfiler.cpp @@ -2,7 +2,7 @@ #include <QProcess> -BaseProfiler::BaseProfiler(BaseInstance *instance, QObject *parent) +BaseProfiler::BaseProfiler(InstancePtr instance, QObject *parent) : BaseExternalTool(instance, parent) { } @@ -29,7 +29,7 @@ void BaseProfiler::abortProfilingImpl() emit abortLaunch(tr("Profiler aborted")); } -BaseProfiler *BaseProfilerFactory::createProfiler(BaseInstance *instance, QObject *parent) +BaseProfiler *BaseProfilerFactory::createProfiler(InstancePtr instance, QObject *parent) { return qobject_cast<BaseProfiler *>(createTool(instance, parent)); } diff --git a/logic/tools/BaseProfiler.h b/logic/tools/BaseProfiler.h index ec57578e..dd841da4 100644 --- a/logic/tools/BaseProfiler.h +++ b/logic/tools/BaseProfiler.h @@ -11,7 +11,7 @@ class BaseProfiler : public BaseExternalTool { Q_OBJECT public: - explicit BaseProfiler(BaseInstance *instance, QObject *parent = 0); + explicit BaseProfiler(InstancePtr instance, QObject *parent = 0); public slots: @@ -32,5 +32,5 @@ signals: class BaseProfilerFactory : public BaseExternalToolFactory { public: - virtual BaseProfiler *createProfiler(BaseInstance *instance, QObject *parent = 0); + virtual BaseProfiler *createProfiler(InstancePtr instance, QObject *parent = 0); }; diff --git a/logic/tools/JProfiler.cpp b/logic/tools/JProfiler.cpp index bb851f0b..35d5d304 100644 --- a/logic/tools/JProfiler.cpp +++ b/logic/tools/JProfiler.cpp @@ -8,7 +8,7 @@ #include "logic/BaseInstance.h" #include "MultiMC.h" -JProfiler::JProfiler(BaseInstance *instance, QObject *parent) : BaseProfiler(instance, parent) +JProfiler::JProfiler(InstancePtr instance, QObject *parent) : BaseProfiler(instance, parent) { } @@ -46,7 +46,7 @@ void JProfilerFactory::registerSettings(SettingsObject *settings) settings->registerSetting("JProfilerPort", 42042); } -BaseExternalTool *JProfilerFactory::createTool(BaseInstance *instance, QObject *parent) +BaseExternalTool *JProfilerFactory::createTool(InstancePtr instance, QObject *parent) { return new JProfiler(instance, parent); } diff --git a/logic/tools/JProfiler.h b/logic/tools/JProfiler.h index 88a02462..b3fa6ec7 100644 --- a/logic/tools/JProfiler.h +++ b/logic/tools/JProfiler.h @@ -6,7 +6,7 @@ class JProfiler : public BaseProfiler { Q_OBJECT public: - JProfiler(BaseInstance *instance, QObject *parent = 0); + JProfiler(InstancePtr instance, QObject *parent = 0); protected: void beginProfilingImpl(MinecraftProcess *process); @@ -17,7 +17,7 @@ class JProfilerFactory : public BaseProfilerFactory public: QString name() const override { return "JProfiler"; } void registerSettings(SettingsObject *settings) override; - BaseExternalTool *createTool(BaseInstance *instance, QObject *parent = 0) override; + BaseExternalTool *createTool(InstancePtr instance, QObject *parent = 0) override; bool check(QString *error) override; bool check(const QString &path, QString *error) override; }; diff --git a/logic/tools/JVisualVM.cpp b/logic/tools/JVisualVM.cpp index 02938028..02e7d8b5 100644 --- a/logic/tools/JVisualVM.cpp +++ b/logic/tools/JVisualVM.cpp @@ -8,7 +8,7 @@ #include "logic/BaseInstance.h" #include "MultiMC.h" -JVisualVM::JVisualVM(BaseInstance *instance, QObject *parent) : BaseProfiler(instance, parent) +JVisualVM::JVisualVM(InstancePtr instance, QObject *parent) : BaseProfiler(instance, parent) { } @@ -47,7 +47,7 @@ void JVisualVMFactory::registerSettings(SettingsObject *settings) settings->registerSetting("JVisualVMPath", defaultValue); } -BaseExternalTool *JVisualVMFactory::createTool(BaseInstance *instance, QObject *parent) +BaseExternalTool *JVisualVMFactory::createTool(InstancePtr instance, QObject *parent) { return new JVisualVM(instance, parent); } diff --git a/logic/tools/JVisualVM.h b/logic/tools/JVisualVM.h index af94fe55..dffdde36 100644 --- a/logic/tools/JVisualVM.h +++ b/logic/tools/JVisualVM.h @@ -6,7 +6,7 @@ class JVisualVM : public BaseProfiler { Q_OBJECT public: - JVisualVM(BaseInstance *instance, QObject *parent = 0); + JVisualVM(InstancePtr instance, QObject *parent = 0); protected: void beginProfilingImpl(MinecraftProcess *process); @@ -17,7 +17,7 @@ class JVisualVMFactory : public BaseProfilerFactory public: QString name() const override { return "JVisualVM"; } void registerSettings(SettingsObject *settings) override; - BaseExternalTool *createTool(BaseInstance *instance, QObject *parent = 0) override; + BaseExternalTool *createTool(InstancePtr instance, QObject *parent = 0) override; bool check(QString *error) override; bool check(const QString &path, QString *error) override; }; diff --git a/logic/tools/MCEditTool.cpp b/logic/tools/MCEditTool.cpp index e22a5d4a..36b8d5bd 100644 --- a/logic/tools/MCEditTool.cpp +++ b/logic/tools/MCEditTool.cpp @@ -9,7 +9,7 @@ #include "logic/BaseInstance.h" #include "MultiMC.h" -MCEditTool::MCEditTool(BaseInstance *instance, QObject *parent) +MCEditTool::MCEditTool(InstancePtr instance, QObject *parent) : BaseDetachedTool(instance, parent) { } @@ -47,7 +47,7 @@ void MCEditFactory::registerSettings(SettingsObject *settings) { settings->registerSetting("MCEditPath"); } -BaseExternalTool *MCEditFactory::createTool(BaseInstance *instance, QObject *parent) +BaseExternalTool *MCEditFactory::createTool(InstancePtr instance, QObject *parent) { return new MCEditTool(instance, parent); } diff --git a/logic/tools/MCEditTool.h b/logic/tools/MCEditTool.h index b0ed1ad4..9985bde1 100644 --- a/logic/tools/MCEditTool.h +++ b/logic/tools/MCEditTool.h @@ -6,7 +6,7 @@ class MCEditTool : public BaseDetachedTool { Q_OBJECT public: - explicit MCEditTool(BaseInstance *instance, QObject *parent = 0); + explicit MCEditTool(InstancePtr instance, QObject *parent = 0); protected: void runImpl() override; @@ -17,7 +17,7 @@ class MCEditFactory : public BaseDetachedToolFactory public: QString name() const override { return "MCEdit"; } void registerSettings(SettingsObject *settings) override; - BaseExternalTool *createTool(BaseInstance *instance, QObject *parent = 0) override; + BaseExternalTool *createTool(InstancePtr instance, QObject *parent = 0) override; bool check(QString *error) override; bool check(const QString &path, QString *error) override; }; |