diff options
author | Petr Mrázek <peterix@gmail.com> | 2019-04-07 23:59:04 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2019-04-07 23:59:04 +0200 |
commit | 70ed30f9e6b47fbfb3151078ca61a2bb419feccb (patch) | |
tree | 0849ab3776d3e716285f3186b4e8e21ee246ee21 /api/logic/minecraft | |
parent | 414946cad94affccddfa500056c6eeb967438643 (diff) | |
download | MultiMC-70ed30f9e6b47fbfb3151078ca61a2bb419feccb.tar MultiMC-70ed30f9e6b47fbfb3151078ca61a2bb419feccb.tar.gz MultiMC-70ed30f9e6b47fbfb3151078ca61a2bb419feccb.tar.lz MultiMC-70ed30f9e6b47fbfb3151078ca61a2bb419feccb.tar.xz MultiMC-70ed30f9e6b47fbfb3151078ca61a2bb419feccb.zip |
GH-2591 less std::shared_ptr and more shared_qobject_ptr
This eliminates some weird crashes.
Diffstat (limited to 'api/logic/minecraft')
-rw-r--r-- | api/logic/minecraft/MinecraftInstance.cpp | 41 | ||||
-rw-r--r-- | api/logic/minecraft/MinecraftInstance.h | 2 | ||||
-rw-r--r-- | api/logic/minecraft/legacy/LegacyInstance.h | 3 |
3 files changed, 21 insertions, 25 deletions
diff --git a/api/logic/minecraft/MinecraftInstance.cpp b/api/logic/minecraft/MinecraftInstance.cpp index 449a2ed5..0d97e4af 100644 --- a/api/logic/minecraft/MinecraftInstance.cpp +++ b/api/logic/minecraft/MinecraftInstance.cpp @@ -777,22 +777,22 @@ shared_qobject_ptr<Task> MinecraftInstance::createUpdateTask(Net::Mode mode) return nullptr; } -std::shared_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr session) +shared_qobject_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr session) { - auto process = LaunchTask::create(std::dynamic_pointer_cast<MinecraftInstance>(getSharedPtr())); + // FIXME: get rid of shared_from_this ... + auto process = LaunchTask::create(std::dynamic_pointer_cast<MinecraftInstance>(shared_from_this())); auto pptr = process.get(); ENV.icons()->saveIcon(iconKey(), FS::PathCombine(gameRoot(), "icon.png"), "PNG"); // print a header { - process->appendStep(std::make_shared<TextPrint>(pptr, "Minecraft folder is:\n" + gameRoot() + "\n\n", MessageLevel::MultiMC)); + process->appendStep(new TextPrint(pptr, "Minecraft folder is:\n" + gameRoot() + "\n\n", MessageLevel::MultiMC)); } // check java { - auto step = std::make_shared<CheckJava>(pptr); - process->appendStep(step); + process->appendStep(new CheckJava(pptr)); } // check launch method @@ -800,14 +800,14 @@ std::shared_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr s QString method = launchMethod(); if(!validMethods.contains(method)) { - process->appendStep(std::make_shared<TextPrint>(pptr, "Selected launch method \"" + method + "\" is not valid.\n", MessageLevel::Fatal)); + process->appendStep(new TextPrint(pptr, "Selected launch method \"" + method + "\" is not valid.\n", MessageLevel::Fatal)); return process; } // run pre-launch command if that's needed if(getPreLaunchCommand().size()) { - auto step = std::make_shared<PreLaunchCommand>(pptr); + auto step = new PreLaunchCommand(pptr); step->setWorkingDirectory(gameRoot()); process->appendStep(step); } @@ -815,42 +815,37 @@ std::shared_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr s // if we aren't in offline mode,. if(session->status != AuthSession::PlayableOffline) { - process->appendStep(std::make_shared<ClaimAccount>(pptr, session)); - process->appendStep(std::make_shared<Update>(pptr, Net::Mode::Online)); + process->appendStep(new ClaimAccount(pptr, session)); + process->appendStep(new Update(pptr, Net::Mode::Online)); } else { - process->appendStep(std::make_shared<Update>(pptr, Net::Mode::Offline)); + process->appendStep(new Update(pptr, Net::Mode::Offline)); } // if there are any jar mods { - auto step = std::make_shared<ModMinecraftJar>(pptr); - process->appendStep(step); + process->appendStep(new ModMinecraftJar(pptr)); } // print some instance info here... { - auto step = std::make_shared<PrintInstanceInfo>(pptr, session); - process->appendStep(step); + process->appendStep(new PrintInstanceInfo(pptr, session)); } // create the server-resource-packs folder (workaround for Minecraft bug MCL-3732) { - auto step = std::make_shared<CreateServerResourcePacksFolder>(pptr); - process->appendStep(step); + process->appendStep(new CreateServerResourcePacksFolder(pptr)); } // extract native jars if needed { - auto step = std::make_shared<ExtractNatives>(pptr); - process->appendStep(step); + process->appendStep(new ExtractNatives(pptr)); } // reconstruct assets if needed { - auto step = std::make_shared<ReconstructAssets>(pptr); - process->appendStep(step); + process->appendStep(new ReconstructAssets(pptr)); } { @@ -858,14 +853,14 @@ std::shared_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr s auto method = launchMethod(); if(method == "LauncherPart") { - auto step = std::make_shared<LauncherPartLaunch>(pptr); + auto step = new LauncherPartLaunch(pptr); step->setWorkingDirectory(gameRoot()); step->setAuthSession(session); process->appendStep(step); } else if (method == "DirectJava") { - auto step = std::make_shared<DirectJavaLaunch>(pptr); + auto step = new DirectJavaLaunch(pptr); step->setWorkingDirectory(gameRoot()); step->setAuthSession(session); process->appendStep(step); @@ -875,7 +870,7 @@ std::shared_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr s // run post-exit command if that's needed if(getPostExitCommand().size()) { - auto step = std::make_shared<PostLaunchCommand>(pptr); + auto step = new PostLaunchCommand(pptr); step->setWorkingDirectory(gameRoot()); process->appendStep(step); } diff --git a/api/logic/minecraft/MinecraftInstance.h b/api/logic/minecraft/MinecraftInstance.h index d9fffe57..fac309c2 100644 --- a/api/logic/minecraft/MinecraftInstance.h +++ b/api/logic/minecraft/MinecraftInstance.h @@ -78,7 +78,7 @@ public: ////// Launch stuff ////// shared_qobject_ptr<Task> createUpdateTask(Net::Mode mode) override; - std::shared_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account) override; + shared_qobject_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account) override; QStringList extraArguments() const override; QStringList verboseDescription(AuthSessionPtr session) override; QList<Mod> getJarMods() const; diff --git a/api/logic/minecraft/legacy/LegacyInstance.h b/api/logic/minecraft/legacy/LegacyInstance.h index 56602a1e..8bbc2d88 100644 --- a/api/logic/minecraft/legacy/LegacyInstance.h +++ b/api/logic/minecraft/legacy/LegacyInstance.h @@ -17,6 +17,7 @@ #include "BaseInstance.h" #include "minecraft/Mod.h" +#include "launch/LaunchTask.h" #include "multimc_logic_export.h" @@ -112,7 +113,7 @@ public: { return false; } - std::shared_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account) override + shared_qobject_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account) override { return nullptr; } |