summaryrefslogtreecommitdiffstats
path: root/logic/OneSixInstance.cpp
diff options
context:
space:
mode:
authorJan Dalheimer <jan@dalheimer.de>2014-03-10 19:24:29 +0100
committerJan Dalheimer <jan@dalheimer.de>2014-03-10 19:24:29 +0100
commitfcc5bc2ce0a1c8c3f9df9230710dd60363eb5cdb (patch)
tree851d8f8b6e6734e26fd2e4dc7b7477630329ff01 /logic/OneSixInstance.cpp
parent73fc9c79cff979e9023df0b1a77848c67b590681 (diff)
parentd11f10ea1ed54336254838ff068258d2d42e0774 (diff)
downloadMultiMC-fcc5bc2ce0a1c8c3f9df9230710dd60363eb5cdb.tar
MultiMC-fcc5bc2ce0a1c8c3f9df9230710dd60363eb5cdb.tar.gz
MultiMC-fcc5bc2ce0a1c8c3f9df9230710dd60363eb5cdb.tar.lz
MultiMC-fcc5bc2ce0a1c8c3f9df9230710dd60363eb5cdb.tar.xz
MultiMC-fcc5bc2ce0a1c8c3f9df9230710dd60363eb5cdb.zip
Merge branch 'develop' into feature_badges
Conflicts: logic/OneSixInstance.cpp
Diffstat (limited to 'logic/OneSixInstance.cpp')
-rw-r--r--logic/OneSixInstance.cpp59
1 files changed, 43 insertions, 16 deletions
diff --git a/logic/OneSixInstance.cpp b/logic/OneSixInstance.cpp
index 148fbc09..ccc25845 100644
--- a/logic/OneSixInstance.cpp
+++ b/logic/OneSixInstance.cpp
@@ -19,7 +19,7 @@
#include "OneSixInstance_p.h"
#include "OneSixUpdate.h"
-#include "OneSixVersion.h"
+#include "VersionFinal.h"
#include "pathutils.h"
#include "logger/QsLog.h"
#include "assets/AssetsUtils.h"
@@ -27,6 +27,7 @@
#include "icons/IconList.h"
#include "MinecraftProcess.h"
#include "gui/dialogs/OneSixModEditDialog.h"
+#include <MMCError.h>
OneSixInstance::OneSixInstance(const QString &rootDir, SettingsObject *settings, QObject *parent)
: BaseInstance(new OneSixInstancePrivate(), rootDir, settings, parent)
@@ -34,15 +35,23 @@ OneSixInstance::OneSixInstance(const QString &rootDir, SettingsObject *settings,
I_D(OneSixInstance);
d->m_settings->registerSetting("IntendedVersion", "");
d->m_settings->registerSetting("ShouldUpdate", false);
- d->version.reset(new OneSixVersion(this, this));
- d->vanillaVersion.reset(new OneSixVersion(this, this));
+ d->version.reset(new VersionFinal(this, this));
+ d->vanillaVersion.reset(new VersionFinal(this, this));
}
void OneSixInstance::init()
{
+ // FIXME: why is this decided here? what does this even mean?
if (QDir(instanceRoot()).exists("version.json"))
{
- reloadVersion();
+ try
+ {
+ reloadVersion();
+ }
+ catch(MMCError & e)
+ {
+ // QLOG_ERROR() << "Caught exception on instance init: " << e.cause();
+ }
}
else
{
@@ -79,7 +88,7 @@ QString replaceTokensIn(QString text, QMap<QString, QString> with)
return result;
}
-QDir OneSixInstance::reconstructAssets(std::shared_ptr<OneSixVersion> version)
+QDir OneSixInstance::reconstructAssets(std::shared_ptr<VersionFinal> version)
{
QDir assetsDir = QDir("assets/");
QDir indexDir = QDir(PathCombine(assetsDir.path(), "indexes"));
@@ -316,25 +325,26 @@ QString OneSixInstance::currentVersionId() const
return intendedVersionId();
}
-bool OneSixInstance::reloadVersion(QWidget *widgetParent)
+void OneSixInstance::reloadVersion()
{
I_D(OneSixInstance);
- bool ret = d->version->reload(widgetParent, false, externalPatches());
- if (ret)
- {
- ret = d->vanillaVersion->reload(widgetParent, true, externalPatches());
- }
- if (ret)
+ try
{
+ d->version->reload(false, externalPatches());
+ d->vanillaVersion->reload(true, externalPatches());
d->m_flags.remove(VersionBrokenFlag);
emit versionReloaded();
}
- else
+ catch(MMCError & error)
{
+ d->version->clear();
+ d->vanillaVersion->clear();
d->m_flags.insert(VersionBrokenFlag);
+ //TODO: rethrow to show some error message(s)?
+ emit versionReloaded();
+ throw;
}
- return ret;
}
void OneSixInstance::clearVersion()
@@ -345,13 +355,13 @@ void OneSixInstance::clearVersion()
emit versionReloaded();
}
-std::shared_ptr<OneSixVersion> OneSixInstance::getFullVersion() const
+std::shared_ptr<VersionFinal> OneSixInstance::getFullVersion() const
{
I_D(const OneSixInstance);
return d->version;
}
-std::shared_ptr<OneSixVersion> OneSixInstance::getVanillaVersion() const
+std::shared_ptr<VersionFinal> OneSixInstance::getVanillaVersion() const
{
I_D(const OneSixInstance);
return d->vanillaVersion;
@@ -413,6 +423,23 @@ bool OneSixInstance::providesVersionFile() const
return false;
}
+bool OneSixInstance::reload()
+{
+ if(BaseInstance::reload())
+ {
+ try
+ {
+ reloadVersion();
+ return true;
+ }
+ catch (...)
+ {
+ return false;
+ }
+ }
+ return false;
+}
+
QString OneSixInstance::loaderModsDir() const
{
return PathCombine(minecraftRoot(), "mods");