From d6dabfa67df9fbde4186e2314c933b47d6959d59 Mon Sep 17 00:00:00 2001 From: arthomnix Date: Mon, 22 May 2023 17:59:26 +0100 Subject: [PATCH] NOISSUE Only reload the pack profile if the cast to MinecraftInstance was successful Prevents a potential segfault if the instance is not a MinecraftInstance --- launcher/ui/dialogs/CreateShortcutDialog.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/launcher/ui/dialogs/CreateShortcutDialog.cpp b/launcher/ui/dialogs/CreateShortcutDialog.cpp index 04955844..934f3a64 100644 --- a/launcher/ui/dialogs/CreateShortcutDialog.cpp +++ b/launcher/ui/dialogs/CreateShortcutDialog.cpp @@ -46,13 +46,17 @@ CreateShortcutDialog::CreateShortcutDialog(QWidget *parent, InstancePtr instance // TODO: check if version is affected by crashing when joining servers on launch, ideally in meta auto mcInstance = std::dynamic_pointer_cast(instance); - mcInstance->getPackProfile()->reload(Net::Mode::Online); - if (mcInstance && mcInstance->getPackProfile()->getComponent("net.minecraft")->getReleaseDateTime() >= g_VersionFilterData.quickPlayBeginsDate) + if (mcInstance) { - mcInstance->worldList()->update(); - for (const auto &world : mcInstance->worldList()->allWorlds()) + mcInstance->getPackProfile()->reload(Net::Mode::Online); + + if (mcInstance->getPackProfile()->getComponent("net.minecraft")->getReleaseDateTime() >= g_VersionFilterData.quickPlayBeginsDate) { - ui->joinSingleplayer->addItem(world.folderName()); + mcInstance->worldList()->update(); + for (const auto &world : mcInstance->worldList()->allWorlds()) + { + ui->joinSingleplayer->addItem(world.folderName()); + } } } else