From 75a7ea55d433a38c2e14f8be67a7e3fc27bba092 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Thu, 2 Jun 2022 21:23:20 +0200 Subject: [PATCH 1/7] feat: implement mod resolving for FTB Signed-off-by: Sefa Eyeoglu --- .../modpacksch/FTBPackInstallTask.cpp | 94 ++++++++++++++++++- .../modpacksch/FTBPackInstallTask.h | 12 ++- .../modpacksch/FTBPackManifest.cpp | 5 +- .../modplatform/modpacksch/FTBPackManifest.h | 7 ++ launcher/ui/pages/modplatform/ftb/FtbPage.cpp | 2 +- 5 files changed, 113 insertions(+), 7 deletions(-) diff --git a/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp b/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp index cac432cdd..c888ef227 100644 --- a/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp +++ b/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp @@ -40,25 +40,32 @@ #include "Json.h" #include "minecraft/MinecraftInstance.h" #include "minecraft/PackProfile.h" +#include "modplatform/flame/PackManifest.h" #include "net/ChecksumValidator.h" +#include "net/Upload.h" #include "settings/INISettingsObject.h" #include "BuildConfig.h" #include "Application.h" +#include "ui/dialogs/ScrollMessageBox.h" namespace ModpacksCH { -PackInstallTask::PackInstallTask(Modpack pack, QString version) +PackInstallTask::PackInstallTask(Modpack pack, QString version, QWidget* parent) { m_pack = pack; m_version_name = version; + m_parent = parent; } bool PackInstallTask::abort() { if(abortable) { - return jobPtr->abort(); + if (modIdResolver) + return modIdResolver->abort(); + else if (jobPtr) + return jobPtr->abort(); } return false; } @@ -118,7 +125,7 @@ void PackInstallTask::onDownloadSucceeded() } m_version = version; - downloadPack(); + resolveMods(); } void PackInstallTask::onDownloadFailed(QString reason) @@ -127,13 +134,92 @@ void PackInstallTask::onDownloadFailed(QString reason) emitFailed(reason); } +void PackInstallTask::resolveMods() +{ + setStatus(tr("Resolving mods...")); + + Flame::Manifest manifest; + indexFileIdMap.clear(); + int index = 0; + for(auto file : m_version.files) { + if(!file.serverOnly && file.url.isEmpty()) { + if(file.curseforge.file <= 0) + emitFailed("Invalid manifest"); // TODO better error + + Flame::File f; + f.projectId = file.curseforge.project; + f.fileId = file.curseforge.file; + f.hash = file.sha1; + + + manifest.files.insert(f.fileId, f); + indexFileIdMap.insert(index, f.fileId); + } + index++; + } + + modIdResolver = new Flame::FileResolvingTask(APPLICATION->network(), manifest); + + connect(modIdResolver.get(), &Flame::FileResolvingTask::succeeded, this, [&]() + { + abortable = false; + + //first check for blocked mods + QString text; + auto anyBlocked = false; + + Flame::Manifest results = modIdResolver->getResults(); + for(int index : indexFileIdMap.keys()) + { + int fileId = indexFileIdMap[index]; + Flame::File foo = results.files[fileId]; + VersionFile &bar = m_version.files[index]; + if (!foo.resolved || foo.url.isEmpty()) + { + QString type = bar.type; + type[0] = type[0].toUpper(); + text += QString("%1: %2 - %3
").arg(type, bar.name, foo.websiteUrl); + anyBlocked = true; + } else { + bar.url = foo.url.toString(); + } + } + if(anyBlocked) { + qWarning() << "Blocked files found, displaying file list"; + + auto message_dialog = new ScrollMessageBox(m_parent, + tr("Blocked files found"), + tr("The following files are not available for download in third party launchers.
" + "You will need to manually download them and add them to the instance."), + text); + message_dialog->setModal(true); + message_dialog->show(); + connect(message_dialog, &QDialog::rejected, [&]() { + modIdResolver.reset(); + emitFailed("Canceled"); + }); + connect(message_dialog, &QDialog::accepted, [&]() { + modIdResolver.reset(); + downloadPack(); + }); + } else { + modIdResolver.reset(); + downloadPack(); + } + }); + connect(modIdResolver.get(), &Flame::FileResolvingTask::failed, this, &PackInstallTask::onDownloadFailed); + + modIdResolver->start(); + abortable = true; +} + void PackInstallTask::downloadPack() { setStatus(tr("Downloading mods...")); jobPtr = new NetJob(tr("Mod download"), APPLICATION->network()); for(auto file : m_version.files) { - if(file.serverOnly) continue; + if(file.serverOnly || file.url.isEmpty()) continue; QFileInfo fileName(file.name); auto cacheName = fileName.completeBaseName() + "-" + file.sha1 + "." + fileName.suffix(); diff --git a/launcher/modplatform/modpacksch/FTBPackInstallTask.h b/launcher/modplatform/modpacksch/FTBPackInstallTask.h index ff59b695c..a85f360a9 100644 --- a/launcher/modplatform/modpacksch/FTBPackInstallTask.h +++ b/launcher/modplatform/modpacksch/FTBPackInstallTask.h @@ -19,9 +19,13 @@ #include "FTBPackManifest.h" +#include "QObjectPtr.h" +#include "modplatform/flame/FileResolvingTask.h" #include "InstanceTask.h" #include "net/NetJob.h" +#include + namespace ModpacksCH { class PackInstallTask : public InstanceTask @@ -29,7 +33,7 @@ class PackInstallTask : public InstanceTask Q_OBJECT public: - explicit PackInstallTask(Modpack pack, QString version); + explicit PackInstallTask(Modpack pack, QString version, QWidget* parent = nullptr); virtual ~PackInstallTask(){} bool canAbort() const override { return true; } @@ -43,6 +47,7 @@ private slots: void onDownloadFailed(QString reason); private: + void resolveMods(); void downloadPack(); void install(); @@ -50,6 +55,9 @@ private: bool abortable = false; NetJob::Ptr jobPtr; + shared_qobject_ptr modIdResolver; + QMap indexFileIdMap; + QByteArray response; Modpack m_pack; @@ -58,6 +66,8 @@ private: QMap filesToCopy; + //FIXME: nuke + QWidget* m_parent; }; } diff --git a/launcher/modplatform/modpacksch/FTBPackManifest.cpp b/launcher/modplatform/modpacksch/FTBPackManifest.cpp index e2d47a5bb..a8c0f6b80 100644 --- a/launcher/modplatform/modpacksch/FTBPackManifest.cpp +++ b/launcher/modplatform/modpacksch/FTBPackManifest.cpp @@ -127,13 +127,16 @@ static void loadVersionFile(ModpacksCH::VersionFile & a, QJsonObject & obj) a.path = Json::requireString(obj, "path"); a.name = Json::requireString(obj, "name"); a.version = Json::requireString(obj, "version"); - a.url = Json::requireString(obj, "url"); + a.url = Json::ensureString(obj, "url"); // optional a.sha1 = Json::requireString(obj, "sha1"); a.size = Json::requireInteger(obj, "size"); a.clientOnly = Json::requireBoolean(obj, "clientonly"); a.serverOnly = Json::requireBoolean(obj, "serveronly"); a.optional = Json::requireBoolean(obj, "optional"); a.updated = Json::requireInteger(obj, "updated"); + auto curseforgeObj = Json::ensureObject(obj, "curseforge"); // optional + a.curseforge.project = Json::ensureInteger(curseforgeObj, "project"); + a.curseforge.file = Json::ensureInteger(curseforgeObj, "file"); } void ModpacksCH::loadVersion(ModpacksCH::Version & m, QJsonObject & obj) diff --git a/launcher/modplatform/modpacksch/FTBPackManifest.h b/launcher/modplatform/modpacksch/FTBPackManifest.h index da45d8ac9..0451127a6 100644 --- a/launcher/modplatform/modpacksch/FTBPackManifest.h +++ b/launcher/modplatform/modpacksch/FTBPackManifest.h @@ -97,6 +97,12 @@ struct VersionTarget int64_t updated; }; +struct VersionFileCurseForge +{ + int project; + int file; +}; + struct VersionFile { int id; @@ -111,6 +117,7 @@ struct VersionFile bool serverOnly; bool optional; int64_t updated; + VersionFileCurseForge curseforge; }; struct Version diff --git a/launcher/ui/pages/modplatform/ftb/FtbPage.cpp b/launcher/ui/pages/modplatform/ftb/FtbPage.cpp index 8a93bc2e3..693ee8840 100644 --- a/launcher/ui/pages/modplatform/ftb/FtbPage.cpp +++ b/launcher/ui/pages/modplatform/ftb/FtbPage.cpp @@ -126,7 +126,7 @@ void FtbPage::suggestCurrent() return; } - dialog->setSuggestedPack(selected.name + " " + selectedVersion, new ModpacksCH::PackInstallTask(selected, selectedVersion)); + dialog->setSuggestedPack(selected.name + " " + selectedVersion, new ModpacksCH::PackInstallTask(selected, selectedVersion, this)); for(auto art : selected.art) { if(art.type == "square") { QString editedLogoName; From fb289c6b1770f43aaeca79df435d72332ad237c3 Mon Sep 17 00:00:00 2001 From: Sefa Eyeoglu Date: Fri, 3 Jun 2022 09:45:09 +0200 Subject: [PATCH 2/7] chore: add license headers Signed-off-by: Sefa Eyeoglu --- .../modpacksch/FTBPackInstallTask.cpp | 1 + .../modpacksch/FTBPackInstallTask.h | 41 ++++++++++++++----- .../modpacksch/FTBPackManifest.cpp | 41 ++++++++++++++----- .../modplatform/modpacksch/FTBPackManifest.h | 41 ++++++++++++++----- launcher/ui/pages/modplatform/ftb/FtbPage.cpp | 1 + 5 files changed, 92 insertions(+), 33 deletions(-) diff --git a/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp b/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp index c888ef227..b335383c5 100644 --- a/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp +++ b/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp @@ -2,6 +2,7 @@ /* * PolyMC - Minecraft Launcher * Copyright (c) 2022 Jamie Mansfield + * Copyright (C) 2022 Sefa Eyeoglu * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/launcher/modplatform/modpacksch/FTBPackInstallTask.h b/launcher/modplatform/modpacksch/FTBPackInstallTask.h index a85f360a9..087794cd6 100644 --- a/launcher/modplatform/modpacksch/FTBPackInstallTask.h +++ b/launcher/modplatform/modpacksch/FTBPackInstallTask.h @@ -1,18 +1,37 @@ +// SPDX-License-Identifier: GPL-3.0-only /* - * Copyright 2020-2021 Jamie Mansfield - * Copyright 2020-2021 Petr Mrazek + * PolyMC - Minecraft Launcher + * Copyright (C) 2022 Sefa Eyeoglu * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * Copyright 2020-2021 Jamie Mansfield + * Copyright 2020-2021 Petr Mrazek + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #pragma once diff --git a/launcher/modplatform/modpacksch/FTBPackManifest.cpp b/launcher/modplatform/modpacksch/FTBPackManifest.cpp index a8c0f6b80..c927a6230 100644 --- a/launcher/modplatform/modpacksch/FTBPackManifest.cpp +++ b/launcher/modplatform/modpacksch/FTBPackManifest.cpp @@ -1,18 +1,37 @@ +// SPDX-License-Identifier: GPL-3.0-only /* - * Copyright 2020 Jamie Mansfield - * Copyright 2020-2021 Petr Mrazek + * PolyMC - Minecraft Launcher + * Copyright (C) 2022 Sefa Eyeoglu * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * Copyright 2020 Jamie Mansfield + * Copyright 2020-2021 Petr Mrazek + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #include "FTBPackManifest.h" diff --git a/launcher/modplatform/modpacksch/FTBPackManifest.h b/launcher/modplatform/modpacksch/FTBPackManifest.h index 0451127a6..dac4e3d0f 100644 --- a/launcher/modplatform/modpacksch/FTBPackManifest.h +++ b/launcher/modplatform/modpacksch/FTBPackManifest.h @@ -1,18 +1,37 @@ +// SPDX-License-Identifier: GPL-3.0-only /* - * Copyright 2020-2021 Jamie Mansfield - * Copyright 2020 Petr Mrazek + * PolyMC - Minecraft Launcher + * Copyright (C) 2022 Sefa Eyeoglu * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * This file incorporates work covered by the following copyright and + * permission notice: + * + * Copyright 2020-2021 Jamie Mansfield + * Copyright 2020 Petr Mrazek + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #pragma once diff --git a/launcher/ui/pages/modplatform/ftb/FtbPage.cpp b/launcher/ui/pages/modplatform/ftb/FtbPage.cpp index 693ee8840..504d7f7b9 100644 --- a/launcher/ui/pages/modplatform/ftb/FtbPage.cpp +++ b/launcher/ui/pages/modplatform/ftb/FtbPage.cpp @@ -2,6 +2,7 @@ /* * PolyMC - Minecraft Launcher * Copyright (c) 2022 Jamie Mansfield + * Copyright (C) 2022 Sefa Eyeoglu * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From e741cb7f0aa651b4f7245aed988ff510c7f8e2f9 Mon Sep 17 00:00:00 2001 From: flow Date: Mon, 25 Jul 2022 16:37:10 -0300 Subject: [PATCH 3/7] fix: add abort handlign in Flame's FileResolvingTask Signed-off-by: flow --- launcher/modplatform/flame/FileResolvingTask.cpp | 7 +++++++ launcher/modplatform/flame/FileResolvingTask.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/launcher/modplatform/flame/FileResolvingTask.cpp b/launcher/modplatform/flame/FileResolvingTask.cpp index c1f56658f..058d24712 100644 --- a/launcher/modplatform/flame/FileResolvingTask.cpp +++ b/launcher/modplatform/flame/FileResolvingTask.cpp @@ -7,6 +7,13 @@ Flame::FileResolvingTask::FileResolvingTask(const shared_qobject_ptrabort(); + return true; +} + void Flame::FileResolvingTask::executeTask() { setStatus(tr("Resolving mod IDs...")); diff --git a/launcher/modplatform/flame/FileResolvingTask.h b/launcher/modplatform/flame/FileResolvingTask.h index 87981f0a4..f71b87ceb 100644 --- a/launcher/modplatform/flame/FileResolvingTask.h +++ b/launcher/modplatform/flame/FileResolvingTask.h @@ -13,6 +13,9 @@ public: explicit FileResolvingTask(const shared_qobject_ptr& network, Flame::Manifest &toProcess); virtual ~FileResolvingTask() {}; + bool canAbort() const override { return true; } + bool abort() override; + const Flame::Manifest &getResults() const { return m_toProcess; From 13372f3f993efcf72c93af5f3169cc01d445f46e Mon Sep 17 00:00:00 2001 From: flow Date: Mon, 25 Jul 2022 16:38:58 -0300 Subject: [PATCH 4/7] chore: clean up FTBPackInstallTask a bit and connect missing signals Signed-off-by: flow --- .../modpacksch/FTBPackInstallTask.cpp | 143 ++++++++++-------- .../modpacksch/FTBPackInstallTask.h | 12 +- 2 files changed, 84 insertions(+), 71 deletions(-) diff --git a/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp b/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp index b335383c5..bad0f1497 100644 --- a/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp +++ b/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp @@ -43,7 +43,6 @@ #include "minecraft/PackProfile.h" #include "modplatform/flame/PackManifest.h" #include "net/ChecksumValidator.h" -#include "net/Upload.h" #include "settings/INISettingsObject.h" #include "BuildConfig.h" @@ -53,26 +52,30 @@ namespace ModpacksCH { PackInstallTask::PackInstallTask(Modpack pack, QString version, QWidget* parent) + : m_pack(std::move(pack)), m_version_name(std::move(version)), m_parent(parent) { - m_pack = pack; - m_version_name = version; - m_parent = parent; } bool PackInstallTask::abort() { - if(abortable) - { - if (modIdResolver) - return modIdResolver->abort(); - else if (jobPtr) - return jobPtr->abort(); - } - return false; + bool aborted = true; + + if (jobPtr) + aborted &= jobPtr->abort(); + if (modIdResolver) + aborted &= modIdResolver->abort(); + + // FIXME: This should be 'emitAborted()', but InstanceStaging doesn't connect to the abort signal yet... + if (aborted) + emitFailed(tr("Aborted")); + + return aborted; } void PackInstallTask::executeTask() { + setStatus(tr("Getting the manifest...")); + // Find pack version bool found = false; VersionInfo version; @@ -91,13 +94,17 @@ void PackInstallTask::executeTask() } auto *netJob = new NetJob("ModpacksCH::VersionFetch", APPLICATION->network()); + auto searchUrl = QString(BuildConfig.MODPACKSCH_API_BASE_URL + "public/modpack/%1/%2").arg(m_pack.id).arg(version.id); netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response)); + jobPtr = netJob; - jobPtr->start(); QObject::connect(netJob, &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded); QObject::connect(netJob, &NetJob::failed, this, &PackInstallTask::onDownloadFailed); + QObject::connect(netJob, &NetJob::progress, this, &PackInstallTask::setProgress); + + jobPtr->start(); } void PackInstallTask::onDownloadSucceeded() @@ -115,15 +122,13 @@ void PackInstallTask::onDownloadSucceeded() auto obj = doc.object(); ModpacksCH::Version version; - try - { + try { ModpacksCH::loadVersion(version, obj); - } - catch (const JSONValidationError &e) - { + } catch (const JSONValidationError &e) { emitFailed(tr("Could not understand pack manifest:\n") + e.cause()); return; } + m_version = version; resolveMods(); @@ -132,29 +137,35 @@ void PackInstallTask::onDownloadSucceeded() void PackInstallTask::onDownloadFailed(QString reason) { jobPtr.reset(); + emitFailed(reason); } void PackInstallTask::resolveMods() { setStatus(tr("Resolving mods...")); + setProgress(0, 100); + + indexFileIdMap.clear(); Flame::Manifest manifest; - indexFileIdMap.clear(); int index = 0; - for(auto file : m_version.files) { + + for(auto const& file : m_version.files) { if(!file.serverOnly && file.url.isEmpty()) { - if(file.curseforge.file <= 0) - emitFailed("Invalid manifest"); // TODO better error + if(file.curseforge.file <= 0) { + emitFailed(QString("Invalid manifest: There's no information available to download the file '%1'!").arg(file.name)); + return; + } - Flame::File f; - f.projectId = file.curseforge.project; - f.fileId = file.curseforge.file; - f.hash = file.sha1; + Flame::File flame_file; + flame_file.projectId = file.curseforge.project; + flame_file.fileId = file.curseforge.file; + flame_file.hash = file.sha1; - manifest.files.insert(f.fileId, f); - indexFileIdMap.insert(index, f.fileId); + manifest.files.insert(flame_file.fileId, flame_file); + indexFileIdMap.insert(index, flame_file.fileId); } index++; } @@ -163,55 +174,56 @@ void PackInstallTask::resolveMods() connect(modIdResolver.get(), &Flame::FileResolvingTask::succeeded, this, [&]() { - abortable = false; + m_abortable = false; - //first check for blocked mods QString text; auto anyBlocked = false; Flame::Manifest results = modIdResolver->getResults(); - for(int index : indexFileIdMap.keys()) - { - int fileId = indexFileIdMap[index]; - Flame::File foo = results.files[fileId]; - VersionFile &bar = m_version.files[index]; - if (!foo.resolved || foo.url.isEmpty()) - { - QString type = bar.type; + for (auto index : indexFileIdMap.keys()) { + int fileId = indexFileIdMap.constFind(index).value(); + + Flame::File results_file = results.files[fileId]; + VersionFile& local_file = m_version.files[index]; + + // First check for blocked mods + if (!results_file.resolved || results_file.url.isEmpty()) { + QString type(local_file.type); + type[0] = type[0].toUpper(); - text += QString("%1: %2 - %3
").arg(type, bar.name, foo.websiteUrl); + text += QString("%1: %2 - %3
").arg(type, local_file.name, results_file.websiteUrl); anyBlocked = true; } else { - bar.url = foo.url.toString(); + local_file.url = results_file.url.toString(); } } - if(anyBlocked) { - qWarning() << "Blocked files found, displaying file list"; + + if (anyBlocked) { + qDebug() << "Blocked files found, displaying file list"; auto message_dialog = new ScrollMessageBox(m_parent, tr("Blocked files found"), tr("The following files are not available for download in third party launchers.
" "You will need to manually download them and add them to the instance."), text); - message_dialog->setModal(true); - message_dialog->show(); - connect(message_dialog, &QDialog::rejected, [&]() { - modIdResolver.reset(); - emitFailed("Canceled"); - }); - connect(message_dialog, &QDialog::accepted, [&]() { + if (message_dialog->exec() == QDialog::Accepted) { modIdResolver.reset(); downloadPack(); - }); + } else { + modIdResolver.reset(); + abort(); + return; + } } else { modIdResolver.reset(); downloadPack(); } }); + connect(modIdResolver.get(), &Flame::FileResolvingTask::failed, this, &PackInstallTask::onDownloadFailed); + connect(modIdResolver.get(), &Flame::FileResolvingTask::progress, this, &PackInstallTask::setProgress); modIdResolver->start(); - abortable = true; } void PackInstallTask::downloadPack() @@ -219,11 +231,12 @@ void PackInstallTask::downloadPack() setStatus(tr("Downloading mods...")); jobPtr = new NetJob(tr("Mod download"), APPLICATION->network()); - for(auto file : m_version.files) { - if(file.serverOnly || file.url.isEmpty()) continue; + for (auto const& file : m_version.files) { + if (file.serverOnly || file.url.isEmpty()) + continue; - QFileInfo fileName(file.name); - auto cacheName = fileName.completeBaseName() + "-" + file.sha1 + "." + fileName.suffix(); + QFileInfo file_info(file.name); + auto cacheName = file_info.completeBaseName() + "-" + file.sha1 + "." + file_info.suffix(); auto entry = APPLICATION->metacache()->resolveEntry("ModpacksCHPacks", cacheName); entry->setStale(true); @@ -235,6 +248,7 @@ void PackInstallTask::downloadPack() qWarning() << "Ignoring" << file.url << "as a file of that path is already downloading."; continue; } + qDebug() << "Will download" << file.url << "to" << path; filesToCopy[path] = entry->getFullPath(); @@ -243,37 +257,36 @@ void PackInstallTask::downloadPack() auto rawSha1 = QByteArray::fromHex(file.sha1.toLatin1()); dl->addValidator(new Net::ChecksumValidator(QCryptographicHash::Sha1, rawSha1)); } + jobPtr->addNetAction(dl); } connect(jobPtr.get(), &NetJob::succeeded, this, [&]() { - abortable = false; jobPtr.reset(); install(); }); connect(jobPtr.get(), &NetJob::failed, [&](QString reason) { - abortable = false; jobPtr.reset(); emitFailed(reason); }); - connect(jobPtr.get(), &NetJob::progress, [&](qint64 current, qint64 total) - { - abortable = true; - setProgress(current, total); - }); + connect(jobPtr.get(), &NetJob::progress, this, &PackInstallTask::setProgress); jobPtr->start(); + + m_abortable = true; } void PackInstallTask::install() { + m_abortable = false; + setStatus(tr("Copying modpack files")); - for (auto iter = filesToCopy.begin(); iter != filesToCopy.end(); iter++) { - auto &to = iter.key(); - auto &from = iter.value(); + for (auto iter = filesToCopy.cbegin(); iter != filesToCopy.cend(); iter++) { + auto& to = iter.key(); + auto& from = iter.value(); FS::copy fileCopyOperation(from, to); if(!fileCopyOperation()) { qWarning() << "Failed to copy" << from << "to" << to; diff --git a/launcher/modplatform/modpacksch/FTBPackInstallTask.h b/launcher/modplatform/modpacksch/FTBPackInstallTask.h index 087794cd6..c32a153ff 100644 --- a/launcher/modplatform/modpacksch/FTBPackInstallTask.h +++ b/launcher/modplatform/modpacksch/FTBPackInstallTask.h @@ -53,13 +53,13 @@ class PackInstallTask : public InstanceTask public: explicit PackInstallTask(Modpack pack, QString version, QWidget* parent = nullptr); - virtual ~PackInstallTask(){} + ~PackInstallTask() override = default; - bool canAbort() const override { return true; } + bool canAbort() const override { return m_abortable; } bool abort() override; protected: - virtual void executeTask() override; + void executeTask() override; private slots: void onDownloadSucceeded(); @@ -71,10 +71,10 @@ private: void install(); private: - bool abortable = false; + bool m_abortable = true; - NetJob::Ptr jobPtr; - shared_qobject_ptr modIdResolver; + NetJob::Ptr jobPtr = nullptr; + shared_qobject_ptr modIdResolver = nullptr; QMap indexFileIdMap; QByteArray response; From 0382f33c46b26b6286d45622c97732c4329ddf7d Mon Sep 17 00:00:00 2001 From: flow Date: Mon, 25 Jul 2022 16:48:29 -0300 Subject: [PATCH 5/7] fix(ui): pump events to show "Copying modpack files..." text Signed-off-by: flow --- .../modplatform/modpacksch/FTBPackInstallTask.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp b/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp index bad0f1497..8483d312e 100644 --- a/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp +++ b/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp @@ -280,10 +280,13 @@ void PackInstallTask::downloadPack() void PackInstallTask::install() { + setStatus(tr("Copying modpack files...")); + setProgress(0, filesToCopy.size()); + QCoreApplication::processEvents(); + m_abortable = false; - setStatus(tr("Copying modpack files")); - + int i = 0; for (auto iter = filesToCopy.cbegin(); iter != filesToCopy.cend(); iter++) { auto& to = iter.key(); auto& from = iter.value(); @@ -293,9 +296,13 @@ void PackInstallTask::install() emitFailed(tr("Failed to copy files")); return; } + + setProgress(i++, filesToCopy.size()); + QCoreApplication::processEvents(); } - setStatus(tr("Installing modpack")); + setStatus(tr("Installing modpack...")); + QCoreApplication::processEvents(); auto instanceConfigPath = FS::PathCombine(m_stagingPath, "instance.cfg"); auto instanceSettings = std::make_shared(instanceConfigPath); From fbf1901d86e67425cd8404c77508395349d80743 Mon Sep 17 00:00:00 2001 From: flow Date: Mon, 25 Jul 2022 17:51:30 -0300 Subject: [PATCH 6/7] refactor: shuffle some things around to improve readability Signed-off-by: flow --- .../modpacksch/FTBPackInstallTask.cpp | 240 +++++++++--------- .../modpacksch/FTBPackInstallTask.h | 25 +- .../modpacksch/FTBPackManifest.cpp | 4 +- .../modplatform/modpacksch/FTBPackManifest.h | 4 +- 4 files changed, 142 insertions(+), 131 deletions(-) diff --git a/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp b/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp index 8483d312e..160130709 100644 --- a/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp +++ b/launcher/modplatform/modpacksch/FTBPackInstallTask.cpp @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-only /* * PolyMC - Minecraft Launcher + * Copyright (C) 2022 flowln * Copyright (c) 2022 Jamie Mansfield * Copyright (C) 2022 Sefa Eyeoglu * @@ -45,25 +46,24 @@ #include "net/ChecksumValidator.h" #include "settings/INISettingsObject.h" -#include "BuildConfig.h" #include "Application.h" +#include "BuildConfig.h" #include "ui/dialogs/ScrollMessageBox.h" namespace ModpacksCH { PackInstallTask::PackInstallTask(Modpack pack, QString version, QWidget* parent) : m_pack(std::move(pack)), m_version_name(std::move(version)), m_parent(parent) -{ -} +{} bool PackInstallTask::abort() { bool aborted = true; - if (jobPtr) - aborted &= jobPtr->abort(); - if (modIdResolver) - aborted &= modIdResolver->abort(); + if (m_net_job) + aborted &= m_net_job->abort(); + if (m_mod_id_resolver_task) + aborted &= m_mod_id_resolver_task->abort(); // FIXME: This should be 'emitAborted()', but InstanceStaging doesn't connect to the abort signal yet... if (aborted) @@ -77,54 +77,48 @@ void PackInstallTask::executeTask() setStatus(tr("Getting the manifest...")); // Find pack version - bool found = false; - VersionInfo version; + auto version_it = std::find_if(m_pack.versions.constBegin(), m_pack.versions.constEnd(), + [this](ModpacksCH::VersionInfo const& a) { return a.name == m_version_name; }); - for(auto vInfo : m_pack.versions) { - if (vInfo.name == m_version_name) { - found = true; - version = vInfo; - break; - } - } - - if(!found) { + if (version_it == m_pack.versions.constEnd()) { emitFailed(tr("Failed to find pack version %1").arg(m_version_name)); return; } - auto *netJob = new NetJob("ModpacksCH::VersionFetch", APPLICATION->network()); + auto version = *version_it; + + auto* netJob = new NetJob("ModpacksCH::VersionFetch", APPLICATION->network()); auto searchUrl = QString(BuildConfig.MODPACKSCH_API_BASE_URL + "public/modpack/%1/%2").arg(m_pack.id).arg(version.id); - netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &response)); + netJob->addNetAction(Net::Download::makeByteArray(QUrl(searchUrl), &m_response)); - jobPtr = netJob; - - QObject::connect(netJob, &NetJob::succeeded, this, &PackInstallTask::onDownloadSucceeded); - QObject::connect(netJob, &NetJob::failed, this, &PackInstallTask::onDownloadFailed); + QObject::connect(netJob, &NetJob::succeeded, this, &PackInstallTask::onManifestDownloadSucceeded); + QObject::connect(netJob, &NetJob::failed, this, &PackInstallTask::onManifestDownloadFailed); QObject::connect(netJob, &NetJob::progress, this, &PackInstallTask::setProgress); - jobPtr->start(); + m_net_job = netJob; + + netJob->start(); } -void PackInstallTask::onDownloadSucceeded() +void PackInstallTask::onManifestDownloadSucceeded() { - jobPtr.reset(); + m_net_job.reset(); - QJsonParseError parse_error; - QJsonDocument doc = QJsonDocument::fromJson(response, &parse_error); - if(parse_error.error != QJsonParseError::NoError) { - qWarning() << "Error while parsing JSON response from ModpacksCH at " << parse_error.offset << " reason: " << parse_error.errorString(); - qWarning() << response; + QJsonParseError parse_error{}; + QJsonDocument doc = QJsonDocument::fromJson(m_response, &parse_error); + if (parse_error.error != QJsonParseError::NoError) { + qWarning() << "Error while parsing JSON response from ModpacksCH at " << parse_error.offset + << " reason: " << parse_error.errorString(); + qWarning() << m_response; return; } - auto obj = doc.object(); - ModpacksCH::Version version; try { + auto obj = Json::requireObject(doc); ModpacksCH::loadVersion(version, obj); - } catch (const JSONValidationError &e) { + } catch (const JSONValidationError& e) { emitFailed(tr("Could not understand pack manifest:\n") + e.cause()); return; } @@ -134,103 +128,98 @@ void PackInstallTask::onDownloadSucceeded() resolveMods(); } -void PackInstallTask::onDownloadFailed(QString reason) -{ - jobPtr.reset(); - - emitFailed(reason); -} - void PackInstallTask::resolveMods() { setStatus(tr("Resolving mods...")); setProgress(0, 100); - indexFileIdMap.clear(); + m_file_id_map.clear(); Flame::Manifest manifest; int index = 0; - for(auto const& file : m_version.files) { - if(!file.serverOnly && file.url.isEmpty()) { - if(file.curseforge.file <= 0) { - emitFailed(QString("Invalid manifest: There's no information available to download the file '%1'!").arg(file.name)); + for (auto const& file : m_version.files) { + if (!file.serverOnly && file.url.isEmpty()) { + if (file.curseforge.file_id <= 0) { + emitFailed(tr("Invalid manifest: There's no information available to download the file '%1'!").arg(file.name)); return; } Flame::File flame_file; - flame_file.projectId = file.curseforge.project; - flame_file.fileId = file.curseforge.file; + flame_file.projectId = file.curseforge.project_id; + flame_file.fileId = file.curseforge.file_id; flame_file.hash = file.sha1; - manifest.files.insert(flame_file.fileId, flame_file); - indexFileIdMap.insert(index, flame_file.fileId); + m_file_id_map.append(flame_file.fileId); + } else { + m_file_id_map.append(-1); } + index++; } - modIdResolver = new Flame::FileResolvingTask(APPLICATION->network(), manifest); + m_mod_id_resolver_task = new Flame::FileResolvingTask(APPLICATION->network(), manifest); - connect(modIdResolver.get(), &Flame::FileResolvingTask::succeeded, this, [&]() - { - m_abortable = false; + connect(m_mod_id_resolver_task.get(), &Flame::FileResolvingTask::succeeded, this, &PackInstallTask::onResolveModsSucceeded); + connect(m_mod_id_resolver_task.get(), &Flame::FileResolvingTask::failed, this, &PackInstallTask::onResolveModsFailed); + connect(m_mod_id_resolver_task.get(), &Flame::FileResolvingTask::progress, this, &PackInstallTask::setProgress); - QString text; - auto anyBlocked = false; + m_mod_id_resolver_task->start(); +} - Flame::Manifest results = modIdResolver->getResults(); - for (auto index : indexFileIdMap.keys()) { - int fileId = indexFileIdMap.constFind(index).value(); +void PackInstallTask::onResolveModsSucceeded() +{ + m_abortable = false; - Flame::File results_file = results.files[fileId]; - VersionFile& local_file = m_version.files[index]; + QString text; + auto anyBlocked = false; - // First check for blocked mods - if (!results_file.resolved || results_file.url.isEmpty()) { - QString type(local_file.type); + Flame::Manifest results = m_mod_id_resolver_task->getResults(); + for (int index = 0; index < m_file_id_map.size(); index++) { + auto const file_id = m_file_id_map.at(index); + if (file_id < 0) + continue; - type[0] = type[0].toUpper(); - text += QString("%1: %2 - %3
").arg(type, local_file.name, results_file.websiteUrl); - anyBlocked = true; - } else { - local_file.url = results_file.url.toString(); - } - } + Flame::File results_file = results.files[file_id]; + VersionFile& local_file = m_version.files[index]; - if (anyBlocked) { - qDebug() << "Blocked files found, displaying file list"; + // First check for blocked mods + if (!results_file.resolved || results_file.url.isEmpty()) { + QString type(local_file.type); - auto message_dialog = new ScrollMessageBox(m_parent, - tr("Blocked files found"), - tr("The following files are not available for download in third party launchers.
" - "You will need to manually download them and add them to the instance."), - text); - if (message_dialog->exec() == QDialog::Accepted) { - modIdResolver.reset(); - downloadPack(); - } else { - modIdResolver.reset(); - abort(); - return; - } + type[0] = type[0].toUpper(); + text += QString("%1: %2 - %3
").arg(type, local_file.name, results_file.websiteUrl); + anyBlocked = true; } else { - modIdResolver.reset(); - downloadPack(); + local_file.url = results_file.url.toString(); } - }); + } - connect(modIdResolver.get(), &Flame::FileResolvingTask::failed, this, &PackInstallTask::onDownloadFailed); - connect(modIdResolver.get(), &Flame::FileResolvingTask::progress, this, &PackInstallTask::setProgress); + m_mod_id_resolver_task.reset(); - modIdResolver->start(); + if (anyBlocked) { + qDebug() << "Blocked files found, displaying file list"; + + auto message_dialog = new ScrollMessageBox(m_parent, tr("Blocked files found"), + tr("The following files are not available for download in third party launchers.
" + "You will need to manually download them and add them to the instance."), + text); + + if (message_dialog->exec() == QDialog::Accepted) + downloadPack(); + else + abort(); + } else { + downloadPack(); + } } void PackInstallTask::downloadPack() { setStatus(tr("Downloading mods...")); - jobPtr = new NetJob(tr("Mod download"), APPLICATION->network()); + auto* jobPtr = new NetJob(tr("Mod download"), APPLICATION->network()); for (auto const& file : m_version.files) { if (file.serverOnly || file.url.isEmpty()) continue; @@ -244,13 +233,13 @@ void PackInstallTask::downloadPack() auto relpath = FS::PathCombine("minecraft", file.path, file.name); auto path = FS::PathCombine(m_stagingPath, relpath); - if (filesToCopy.contains(path)) { + if (m_files_to_copy.contains(path)) { qWarning() << "Ignoring" << file.url << "as a file of that path is already downloading."; continue; } qDebug() << "Will download" << file.url << "to" << path; - filesToCopy[path] = entry->getFullPath(); + m_files_to_copy[path] = entry->getFullPath(); auto dl = Net::Download::makeCached(file.url, entry); if (!file.sha1.isEmpty()) { @@ -261,43 +250,42 @@ void PackInstallTask::downloadPack() jobPtr->addNetAction(dl); } - connect(jobPtr.get(), &NetJob::succeeded, this, [&]() - { - jobPtr.reset(); - install(); - }); - connect(jobPtr.get(), &NetJob::failed, [&](QString reason) - { - jobPtr.reset(); - emitFailed(reason); - }); - connect(jobPtr.get(), &NetJob::progress, this, &PackInstallTask::setProgress); + connect(jobPtr, &NetJob::succeeded, this, &PackInstallTask::onModDownloadSucceeded); + connect(jobPtr, &NetJob::failed, this, &PackInstallTask::onModDownloadFailed); + connect(jobPtr, &NetJob::progress, this, &PackInstallTask::setProgress); + m_net_job = jobPtr; jobPtr->start(); m_abortable = true; } +void PackInstallTask::onModDownloadSucceeded() +{ + m_net_job.reset(); + install(); +} + void PackInstallTask::install() { setStatus(tr("Copying modpack files...")); - setProgress(0, filesToCopy.size()); + setProgress(0, m_files_to_copy.size()); QCoreApplication::processEvents(); m_abortable = false; int i = 0; - for (auto iter = filesToCopy.cbegin(); iter != filesToCopy.cend(); iter++) { + for (auto iter = m_files_to_copy.constBegin(); iter != m_files_to_copy.constEnd(); iter++) { auto& to = iter.key(); auto& from = iter.value(); FS::copy fileCopyOperation(from, to); - if(!fileCopyOperation()) { + if (!fileCopyOperation()) { qWarning() << "Failed to copy" << from << "to" << to; emitFailed(tr("Failed to copy files")); return; } - setProgress(i++, filesToCopy.size()); + setProgress(i++, m_files_to_copy.size()); QCoreApplication::processEvents(); } @@ -312,20 +300,20 @@ void PackInstallTask::install() auto components = instance.getPackProfile(); components->buildingFromScratch(); - for(auto target : m_version.targets) { - if(target.type == "game" && target.name == "minecraft") { + for (auto target : m_version.targets) { + if (target.type == "game" && target.name == "minecraft") { components->setComponentVersion("net.minecraft", target.version, true); break; } } - for(auto target : m_version.targets) { - if(target.type != "modloader") continue; + for (auto target : m_version.targets) { + if (target.type != "modloader") + continue; - if(target.name == "forge") { + if (target.name == "forge") { components->setComponentVersion("net.minecraftforge", target.version); - } - else if(target.name == "fabric") { + } else if (target.name == "fabric") { components->setComponentVersion("net.fabricmc.fabric-loader", target.version); } } @@ -352,4 +340,20 @@ void PackInstallTask::install() emitSucceeded(); } +void PackInstallTask::onManifestDownloadFailed(QString reason) +{ + m_net_job.reset(); + emitFailed(reason); } +void PackInstallTask::onResolveModsFailed(QString reason) +{ + m_net_job.reset(); + emitFailed(reason); +} +void PackInstallTask::onModDownloadFailed(QString reason) +{ + m_net_job.reset(); + emitFailed(reason); +} + +} // namespace ModpacksCH diff --git a/launcher/modplatform/modpacksch/FTBPackInstallTask.h b/launcher/modplatform/modpacksch/FTBPackInstallTask.h index c32a153ff..e63ca0dff 100644 --- a/launcher/modplatform/modpacksch/FTBPackInstallTask.h +++ b/launcher/modplatform/modpacksch/FTBPackInstallTask.h @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-3.0-only /* * PolyMC - Minecraft Launcher + * Copyright (C) 2022 flowln * Copyright (C) 2022 Sefa Eyeoglu * * This program is free software: you can redistribute it and/or modify @@ -38,16 +39,16 @@ #include "FTBPackManifest.h" +#include "InstanceTask.h" #include "QObjectPtr.h" #include "modplatform/flame/FileResolvingTask.h" -#include "InstanceTask.h" #include "net/NetJob.h" #include namespace ModpacksCH { -class PackInstallTask : public InstanceTask +class PackInstallTask final : public InstanceTask { Q_OBJECT @@ -62,8 +63,13 @@ protected: void executeTask() override; private slots: - void onDownloadSucceeded(); - void onDownloadFailed(QString reason); + void onManifestDownloadSucceeded(); + void onResolveModsSucceeded(); + void onModDownloadSucceeded(); + + void onManifestDownloadFailed(QString reason); + void onResolveModsFailed(QString reason); + void onModDownloadFailed(QString reason); private: void resolveMods(); @@ -73,17 +79,18 @@ private: private: bool m_abortable = true; - NetJob::Ptr jobPtr = nullptr; - shared_qobject_ptr modIdResolver = nullptr; - QMap indexFileIdMap; + NetJob::Ptr m_net_job = nullptr; + shared_qobject_ptr m_mod_id_resolver_task = nullptr; - QByteArray response; + QList m_file_id_map; + + QByteArray m_response; Modpack m_pack; QString m_version_name; Version m_version; - QMap filesToCopy; + QMap m_files_to_copy; //FIXME: nuke QWidget* m_parent; diff --git a/launcher/modplatform/modpacksch/FTBPackManifest.cpp b/launcher/modplatform/modpacksch/FTBPackManifest.cpp index c927a6230..421527aef 100644 --- a/launcher/modplatform/modpacksch/FTBPackManifest.cpp +++ b/launcher/modplatform/modpacksch/FTBPackManifest.cpp @@ -154,8 +154,8 @@ static void loadVersionFile(ModpacksCH::VersionFile & a, QJsonObject & obj) a.optional = Json::requireBoolean(obj, "optional"); a.updated = Json::requireInteger(obj, "updated"); auto curseforgeObj = Json::ensureObject(obj, "curseforge"); // optional - a.curseforge.project = Json::ensureInteger(curseforgeObj, "project"); - a.curseforge.file = Json::ensureInteger(curseforgeObj, "file"); + a.curseforge.project_id = Json::ensureInteger(curseforgeObj, "project"); + a.curseforge.file_id = Json::ensureInteger(curseforgeObj, "file"); } void ModpacksCH::loadVersion(ModpacksCH::Version & m, QJsonObject & obj) diff --git a/launcher/modplatform/modpacksch/FTBPackManifest.h b/launcher/modplatform/modpacksch/FTBPackManifest.h index dac4e3d0f..a8b6f35ec 100644 --- a/launcher/modplatform/modpacksch/FTBPackManifest.h +++ b/launcher/modplatform/modpacksch/FTBPackManifest.h @@ -118,8 +118,8 @@ struct VersionTarget struct VersionFileCurseForge { - int project; - int file; + int project_id; + int file_id; }; struct VersionFile From 1ce0f0e7a5059527cea3c6da84c19eb3599d2eff Mon Sep 17 00:00:00 2001 From: flow Date: Mon, 25 Jul 2022 17:52:55 -0300 Subject: [PATCH 7/7] fix: progress dialog going away even if the task was not aborted Signed-off-by: flow --- launcher/ui/dialogs/ProgressDialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/launcher/ui/dialogs/ProgressDialog.cpp b/launcher/ui/dialogs/ProgressDialog.cpp index a79bc8373..3c7f53d34 100644 --- a/launcher/ui/dialogs/ProgressDialog.cpp +++ b/launcher/ui/dialogs/ProgressDialog.cpp @@ -43,8 +43,8 @@ void ProgressDialog::setSkipButton(bool present, QString label) void ProgressDialog::on_skipButton_clicked(bool checked) { Q_UNUSED(checked); - task->abort(); - QDialog::reject(); + if (task->abort()) + QDialog::reject(); } ProgressDialog::~ProgressDialog()