From 572a6026b57804cd8e9c3a4ccf4dcb1d198b46c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 21 May 2017 02:34:02 +0200 Subject: GH-1895 update LWJGL list during legacy instance update --- api/logic/minecraft/legacy/LegacyUpdate.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'api/logic/minecraft/legacy/LegacyUpdate.cpp') diff --git a/api/logic/minecraft/legacy/LegacyUpdate.cpp b/api/logic/minecraft/legacy/LegacyUpdate.cpp index 337a3e4e..e263d0de 100644 --- a/api/logic/minecraft/legacy/LegacyUpdate.cpp +++ b/api/logic/minecraft/legacy/LegacyUpdate.cpp @@ -164,6 +164,20 @@ void LegacyUpdate::lwjglStart() { LegacyInstance *inst = (LegacyInstance *)m_inst; + auto list = std::dynamic_pointer_cast(ENV.getVersionList("org.lwjgl.legacy")); + if (!list->isLoaded()) + { + setStatus(tr("Checking the LWJGL version list...")); + list->loadList(); + auto task = list->getLoadTask(); + connect(task.get(), &Task::succeeded, this, &LegacyUpdate::lwjglStart); + connect(task.get(), &Task::failed, this, [&](const QString & error) + { + emitFailed(tr("Failed to refresh LWJGL list: %1.").arg(error)); + }); + return; + } + lwjglVersion = inst->lwjglVersion(); lwjglTargetPath = FS::PathCombine(inst->lwjglFolder(), lwjglVersion); lwjglNativesPath = FS::PathCombine(lwjglTargetPath, "natives"); @@ -176,18 +190,11 @@ void LegacyUpdate::lwjglStart() return; } - auto list = std::dynamic_pointer_cast(ENV.getVersionList("org.lwjgl.legacy")); - if (!list->isLoaded()) - { - emitFailed("Too soon! Let the LWJGL list load :)"); - return; - } - setStatus(tr("Downloading new LWJGL...")); auto version = std::dynamic_pointer_cast(list->findVersion(lwjglVersion)); if (!version) { - emitFailed("Game update failed: the selected LWJGL version is invalid."); + emitFailed(QString("Game update failed: the selected LWJGL version is invalid: %1").arg(lwjglVersion)); return; } -- cgit v1.2.3