From cf43abc87ef56247e3012fa0d1fcefe7cb561824 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 22 Jan 2017 15:20:05 +0100 Subject: GH-1794 Only write to the instance.cfg once after copying FTB instances. --- api/logic/BaseInstance.h | 2 +- api/logic/InstanceCopyTask.cpp | 2 +- api/logic/minecraft/ftb/OneSixFTBInstance.cpp | 7 ++----- api/logic/minecraft/ftb/OneSixFTBInstance.h | 2 +- 4 files changed, 5 insertions(+), 8 deletions(-) (limited to 'api') diff --git a/api/logic/BaseInstance.h b/api/logic/BaseInstance.h index 3a551a5b..462b7c66 100644 --- a/api/logic/BaseInstance.h +++ b/api/logic/BaseInstance.h @@ -67,7 +67,7 @@ public: /// virtual destructor to make sure the destruction is COMPLETE virtual ~BaseInstance() {}; - virtual void copy(const QDir &newDir) {} + virtual void copy(SettingsObjectPtr newSettings, const QDir &newDir) {} virtual void init() = 0; diff --git a/api/logic/InstanceCopyTask.cpp b/api/logic/InstanceCopyTask.cpp index 20c09907..b1bd39ef 100644 --- a/api/logic/InstanceCopyTask.cpp +++ b/api/logic/InstanceCopyTask.cpp @@ -51,7 +51,7 @@ void InstanceCopyTask::copyFinished() instanceSettings->registerSetting("InstanceType", "Legacy"); // FIXME: and this too? errors??? - m_origInstance->copy(m_stagingPath); + m_origInstance->copy(instanceSettings, m_stagingPath); InstancePtr inst(new NullInstance(m_globalSettings, instanceSettings, m_stagingPath)); inst->setName(m_instName); diff --git a/api/logic/minecraft/ftb/OneSixFTBInstance.cpp b/api/logic/minecraft/ftb/OneSixFTBInstance.cpp index 5edad080..edf31eb7 100644 --- a/api/logic/minecraft/ftb/OneSixFTBInstance.cpp +++ b/api/logic/minecraft/ftb/OneSixFTBInstance.cpp @@ -15,7 +15,7 @@ OneSixFTBInstance::OneSixFTBInstance(SettingsObjectPtr globalSettings, SettingsO m_globalSettings = globalSettings; } -void OneSixFTBInstance::copy(const QDir &newDir) +void OneSixFTBInstance::copy(SettingsObjectPtr newSettings, const QDir &newDir) { QStringList libraryNames; // create patch file @@ -94,10 +94,7 @@ void OneSixFTBInstance::copy(const QDir &newDir) } } // now set the target instance to be plain OneSix - INISettingsObject settings_obj(newDir.absoluteFilePath("instance.cfg")); - settings_obj.registerSetting("InstanceType", "Legacy"); - QString inst_type = settings_obj.get("InstanceType").toString(); - settings_obj.set("InstanceType", "OneSix"); + newSettings->set("InstanceType", "OneSix"); } QString OneSixFTBInstance::id() const diff --git a/api/logic/minecraft/ftb/OneSixFTBInstance.h b/api/logic/minecraft/ftb/OneSixFTBInstance.h index a5621685..640f609c 100644 --- a/api/logic/minecraft/ftb/OneSixFTBInstance.h +++ b/api/logic/minecraft/ftb/OneSixFTBInstance.h @@ -9,7 +9,7 @@ public: explicit OneSixFTBInstance(SettingsObjectPtr globalSettings, SettingsObjectPtr settings, const QString &rootDir); virtual ~OneSixFTBInstance(){}; - void copy(const QDir &newDir) override; + void copy(SettingsObjectPtr newSettings, const QDir &newDir) override; virtual void createProfile() override; -- cgit v1.2.3