NOISSUE Only reload the pack profile if the cast to MinecraftInstance was successful

Prevents a potential segfault if the instance is not a MinecraftInstance
This commit is contained in:
arthomnix 2023-05-22 17:59:26 +01:00
parent 29c78b56fc
commit d6dabfa67d

View File

@ -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<MinecraftInstance>(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