diff options
author | Petr Mrázek <peterix@gmail.com> | 2013-09-22 04:21:36 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2013-09-22 04:21:36 +0200 |
commit | ceca6959d2a7f258d62ac4f589095b65084706c3 (patch) | |
tree | 8ce02eb4713bf8e770e02e97c99ad45f492cc688 /MultiMC.cpp | |
parent | c2c7293083de8e8d40190992ccd6a65b613a4d06 (diff) | |
download | MultiMC-ceca6959d2a7f258d62ac4f589095b65084706c3.tar MultiMC-ceca6959d2a7f258d62ac4f589095b65084706c3.tar.gz MultiMC-ceca6959d2a7f258d62ac4f589095b65084706c3.tar.lz MultiMC-ceca6959d2a7f258d62ac4f589095b65084706c3.tar.xz MultiMC-ceca6959d2a7f258d62ac4f589095b65084706c3.zip |
Working 1.6 modding (currently only forge)
Diffstat (limited to 'MultiMC.cpp')
-rw-r--r-- | MultiMC.cpp | 70 |
1 files changed, 26 insertions, 44 deletions
diff --git a/MultiMC.cpp b/MultiMC.cpp index 4b5b40b2..decc22bf 100644 --- a/MultiMC.cpp +++ b/MultiMC.cpp @@ -123,7 +123,7 @@ MultiMC::MultiMC ( int& argc, char** argv ) initGlobalSettings(); // and instances - m_instances = new InstanceList(m_settings->get("InstanceDir").toString(),this); + m_instances.reset(new InstanceList(m_settings->get("InstanceDir").toString(),this)); std::cout << "Loading Instances..." << std::endl; m_instances->loadList(); @@ -131,7 +131,7 @@ MultiMC::MultiMC ( int& argc, char** argv ) initHttpMetaCache(); // create the global network manager - m_qnam = new QNetworkAccessManager(this); + m_qnam.reset(new QNetworkAccessManager(this)); // Register meta types. qRegisterMetaType<LoginResponse>("LoginResponse"); @@ -152,80 +152,59 @@ MultiMC::~MultiMC() { if(m_mmc_translator) { - removeTranslator(m_mmc_translator); - delete m_mmc_translator; - m_mmc_translator = nullptr; + removeTranslator(m_mmc_translator.data()); } if(m_qt_translator) { - removeTranslator(m_qt_translator); - delete m_qt_translator; - m_qt_translator = nullptr; + removeTranslator(m_qt_translator.data()); } - if(m_icons) - { - delete m_icons; - m_icons = nullptr; - } - if(m_lwjgllist) - { - delete m_lwjgllist; - m_lwjgllist = nullptr; - } - if(m_minecraftlist) - { - delete m_minecraftlist; - m_minecraftlist = nullptr; - } - delete m_settings; - delete m_metacache; } void MultiMC::initTranslations() { - m_qt_translator = new QTranslator(); + m_qt_translator.reset(new QTranslator()); if(m_qt_translator->load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath))) { std::cout << "Loading Qt Language File for " << QLocale::system().name().toLocal8Bit().constData() << "..."; - if(!installTranslator(m_qt_translator)) + if(!installTranslator(m_qt_translator.data())) { std::cout << " failed."; + m_qt_translator.reset(); } std::cout << std::endl; } else { - delete m_qt_translator; - m_qt_translator = nullptr; + m_qt_translator.reset(); } - m_mmc_translator = new QTranslator(); + m_mmc_translator.reset(new QTranslator()); if(m_mmc_translator->load("mmc_" + QLocale::system().name(), QDir("translations").absolutePath())) { std::cout << "Loading MMC Language File for " << QLocale::system().name().toLocal8Bit().constData() << "..."; - if(!installTranslator(m_mmc_translator)) + if(!installTranslator(m_mmc_translator.data())) { std::cout << " failed."; + m_mmc_translator.reset(); } std::cout << std::endl; } else { - delete m_mmc_translator; - m_mmc_translator = nullptr; + m_mmc_translator.reset(); } } void MultiMC::initGlobalSettings() { - m_settings = new INISettingsObject("multimc.cfg", this); + m_settings.reset(new INISettingsObject("multimc.cfg", this)); // Updates m_settings->registerSetting(new Setting("UseDevBuilds", false)); m_settings->registerSetting(new Setting("AutoUpdate", true)); @@ -278,7 +257,7 @@ void MultiMC::initGlobalSettings() void MultiMC::initHttpMetaCache() { - m_metacache = new HttpMetaCache("metacache"); + m_metacache.reset(new HttpMetaCache("metacache")); m_metacache->addBase("assets", QDir("assets").absolutePath()); m_metacache->addBase("versions", QDir("versions").absolutePath()); m_metacache->addBase("libraries", QDir("libraries").absolutePath()); @@ -287,37 +266,38 @@ void MultiMC::initHttpMetaCache() } -IconList* MultiMC::icons() +QSharedPointer<IconList> MultiMC::icons() { if ( !m_icons ) { - m_icons = new IconList; + m_icons.reset(new IconList); } return m_icons; } -LWJGLVersionList* MultiMC::lwjgllist() +QSharedPointer<LWJGLVersionList> MultiMC::lwjgllist() { if ( !m_lwjgllist ) { - m_lwjgllist = new LWJGLVersionList(); + m_lwjgllist.reset(new LWJGLVersionList()); } return m_lwjgllist; } -ForgeVersionList* MultiMC::forgelist() + +QSharedPointer<ForgeVersionList> MultiMC::forgelist() { if ( !m_forgelist ) { - m_forgelist = new ForgeVersionList(); + m_forgelist.reset(new ForgeVersionList()); } return m_forgelist; } -MinecraftVersionList* MultiMC::minecraftlist() +QSharedPointer<MinecraftVersionList> MultiMC::minecraftlist() { if ( !m_minecraftlist ) { - m_minecraftlist = new MinecraftVersionList(); + m_minecraftlist.reset(new MinecraftVersionList()); } return m_minecraftlist; } @@ -345,4 +325,6 @@ int main(int argc, char *argv[]) } } -#include "MultiMC.moc"
\ No newline at end of file +#include "MultiMC.moc" + + |