From cbe143c26679282ac1dba6c6c8e0e1e8360c5e28 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 8 May 2026 23:38:49 +0300 Subject: [PATCH] chore(clang-tidy): fix clang tidy warnings Signed-off-by: Trial97 --- launcher/BaseInstance.cpp | 6 +- launcher/BaseInstance.h | 2 +- launcher/InstanceList.cpp | 10 +- launcher/InstanceList.h | 2 +- launcher/InstanceTask.h | 1 + .../minecraft/VanillaInstanceCreationTask.cpp | 2 +- .../flame/FlameInstanceCreationTask.cpp | 24 ++--- .../modplatform/ftb/FTBPackInstallTask.cpp | 94 ++++++++++--------- .../import_ftb/PackInstallTask.cpp | 4 +- .../modplatform/import_ftb/PackInstallTask.h | 10 +- .../legacy_ftb/PackInstallTask.cpp | 36 ++++--- .../modplatform/legacy_ftb/PackInstallTask.h | 18 ++-- .../modrinth/ModrinthInstanceCreationTask.cpp | 12 +-- .../ui/pages/instance/ManagedPackPage.cpp | 4 +- 14 files changed, 115 insertions(+), 110 deletions(-) diff --git a/launcher/BaseInstance.cpp b/launcher/BaseInstance.cpp index 3167b296b..d65e07df0 100644 --- a/launcher/BaseInstance.cpp +++ b/launcher/BaseInstance.cpp @@ -68,8 +68,8 @@ bool shouldStopOnConsoleOverflow(SettingsObject* settings) return settings->get("ConsoleOverflowStop").toBool(); } -BaseInstance::BaseInstance(SettingsObject* globalSettings, std::unique_ptr settings, const QString& rootDir) - : m_rootDir(rootDir), m_settings(std::move(settings)), m_global_settings(globalSettings) +BaseInstance::BaseInstance(SettingsObject* globalSettings, std::unique_ptr settings, QString rootDir) + : m_rootDir(std::move(rootDir)), m_settings(std::move(settings)), m_global_settings(globalSettings) { m_settings->registerSetting("name", "Unnamed Instance"); m_settings->registerSetting("iconKey", "default"); @@ -423,7 +423,7 @@ QList BaseInstance::shortcuts() const continue; } int value = dict["target"].toInt(-1); - if (!dict["name"].isString() || !dict["filePath"].isString() || value < 0 || value >= 3) { + if (!dict.value("name").isString() || !dict.value("filePath").isString() || value < 0 || value >= 3) { continue; } diff --git a/launcher/BaseInstance.h b/launcher/BaseInstance.h index 7e28ea1d4..c789a4525 100644 --- a/launcher/BaseInstance.h +++ b/launcher/BaseInstance.h @@ -86,7 +86,7 @@ class BaseInstance : public QObject { Q_OBJECT protected: /// no-touchy! - BaseInstance(SettingsObject* globalSettings, std::unique_ptr settings, const QString& rootDir); + BaseInstance(SettingsObject* globalSettings, std::unique_ptr settings, QString rootDir); public: /* types */ enum class Status : std::uint8_t { diff --git a/launcher/InstanceList.cpp b/launcher/InstanceList.cpp index 29b2f3680..3cdfe7942 100644 --- a/launcher/InstanceList.cpp +++ b/launcher/InstanceList.cpp @@ -553,7 +553,7 @@ InstanceList::InstListError InstanceList::loadList() removeNow(); } } - if (newList.size() != 0U) { + if (!newList.empty()) { add(newList); } m_dirty = false; @@ -565,7 +565,7 @@ void InstanceList::updateTotalPlayTime() { m_totalPlayTime = 0; for (const auto& itr : m_instances) { - m_totalPlayTime += itr->totalTimePlayed(); + m_totalPlayTime += static_cast(itr->totalTimePlayed()); } } @@ -676,7 +676,7 @@ std::unique_ptr InstanceList::loadInstance(const InstanceId& id) instanceSettings->registerSetting("InstanceType", ""); - QString instType = instanceSettings->get("InstanceType").toString(); + const QString instType = instanceSettings->get("InstanceType").toString(); // NOTE: Some launcher versions didn't save the InstanceType properly. We will just bank on the probability that this is probably a // OneSix instance @@ -886,7 +886,7 @@ void InstanceList::instanceDirContentsChanged(const QString& path) emit instancesChanged(); } -void InstanceList::on_InstFolderChanged([[maybe_unused]] const Setting& setting, const QVariant value) +void InstanceList::on_InstFolderChanged([[maybe_unused]] const Setting& setting, const QVariant& value) { QString newInstDir = QDir(value.toString()).canonicalPath(); if (newInstDir != m_instDir) { @@ -971,7 +971,7 @@ class InstanceStaging : public Task { private slots: void childSucceeded() { - unsigned sleepTime = m_backoff(); + const unsigned sleepTime = m_backoff(); if (m_parent->commitStagedInstance(m_stagingPath, *m_child, m_child->group())) { m_backoffTimer.stop(); emitSucceeded(); diff --git a/launcher/InstanceList.h b/launcher/InstanceList.h index c963e50cb..e3ecabca3 100644 --- a/launcher/InstanceList.h +++ b/launcher/InstanceList.h @@ -160,7 +160,7 @@ class InstanceList : public QAbstractListModel { void groupsChanged(QSet groups); public slots: - void on_InstFolderChanged(const Setting& setting, QVariant value); + void on_InstFolderChanged(const Setting& setting, const QVariant& value); void on_GroupStateChanged(const QString& group, bool collapsed); private slots: diff --git a/launcher/InstanceTask.h b/launcher/InstanceTask.h index 1394b1973..76a3e84c2 100644 --- a/launcher/InstanceTask.h +++ b/launcher/InstanceTask.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include "settings/SettingsObject.h" #include "tasks/Task.h" diff --git a/launcher/minecraft/VanillaInstanceCreationTask.cpp b/launcher/minecraft/VanillaInstanceCreationTask.cpp index 83fa6c9ba..fb059f59a 100644 --- a/launcher/minecraft/VanillaInstanceCreationTask.cpp +++ b/launcher/minecraft/VanillaInstanceCreationTask.cpp @@ -18,7 +18,7 @@ void VanillaCreationTask::executeTask() m_instance = std::make_unique( m_globalSettings, std::make_unique(FS::PathCombine(m_stagingPath, "instance.cfg")), m_stagingPath); { - SettingsObject::Lock lock(m_instance->settings()); + SettingsObject::Lock const lock(m_instance->settings()); auto* components = m_instance->getPackProfile(); components->buildingFromScratch(); diff --git a/launcher/modplatform/flame/FlameInstanceCreationTask.cpp b/launcher/modplatform/flame/FlameInstanceCreationTask.cpp index e9e147fda..cfa2b1167 100644 --- a/launcher/modplatform/flame/FlameInstanceCreationTask.cpp +++ b/launcher/modplatform/flame/FlameInstanceCreationTask.cpp @@ -135,12 +135,12 @@ void FlameCreationTask::executeTask() } } - QDir oldInstDir(inst->instanceRoot()); + QDir const oldInstDir(inst->instanceRoot()); - QString oldIndexFolder(FS::PathCombine(oldInstDir.absolutePath(), "flame")); - QString oldIndexPath(FS::PathCombine(oldIndexFolder, "manifest.json")); + QString const oldIndexFolder(FS::PathCombine(oldInstDir.absolutePath(), "flame")); + QString const oldIndexPath(FS::PathCombine(oldIndexFolder, "manifest.json")); - QFileInfo oldIndexFile(oldIndexPath); + QFileInfo const oldIndexFile(oldIndexPath); auto createInst = [this, inst] { setOverride(true, inst->id()); qDebug() << "Will override instance!"; @@ -194,7 +194,7 @@ void FlameCreationTask::executeTask() filesIterator++; } - QDir oldMinecraftDir(inst->gameRoot()); + QDir const oldMinecraftDir(inst->gameRoot()); // We will remove all the previous overrides, to prevent duplicate files! // TODO: Currently 'overrides' will always override the stuff on update. How do we preserve unchanged overrides? @@ -252,7 +252,7 @@ void FlameCreationTask::executeTask() continue; } - QString relativePath(FS::PathCombine(file.targetFolder, file.version.fileName)); + QString const relativePath(FS::PathCombine(file.targetFolder, file.version.fileName)); scheduleToDelete(m_parent, oldMinecraftDir, relativePath, true); } @@ -345,16 +345,16 @@ void FlameCreationTask::setManagedPack(BaseInstance* instance) void FlameCreationTask::createInstance() { - QString parentFolder(FS::PathCombine(m_stagingPath, "flame")); + QString const parentFolder(FS::PathCombine(m_stagingPath, "flame")); try { - QString indexPath(FS::PathCombine(m_stagingPath, "manifest.json")); + QString const indexPath(FS::PathCombine(m_stagingPath, "manifest.json")); if (!m_pack.isLoaded) { Flame::loadManifest(m_pack, indexPath); } // Keep index file in case we need it some other time (like when changing versions) - QString newIndexPlace(FS::PathCombine(parentFolder, "manifest.json")); + QString const newIndexPlace(FS::PathCombine(parentFolder, "manifest.json")); FS::ensureFilePathExists(newIndexPlace); FS::move(indexPath, newIndexPlace); @@ -621,8 +621,8 @@ void FlameCreationTask::copyBlockedMods(const QList& blockedMods) setStatus(tr("Copying Blocked Mods...")); setAbortable(false); int i = 0; - int total = blockedMods.length(); - setProgress(i, total); + auto const total = blockedMods.length(); + setProgress(i, static_cast(total)); for (const auto& mod : blockedMods) { if (!mod.matched) { qDebug() << mod.name << "was not matched to a local file, skipping copy"; @@ -745,7 +745,7 @@ void FlameCreationTask::finishInstall() // Update information of the already installed instance, if any. if (m_oldInstance) { setAbortable(false); - setManagedPack(m_oldInstance.value()); + setManagedPack(*m_oldInstance); } if (shouldOverride()) { diff --git a/launcher/modplatform/ftb/FTBPackInstallTask.cpp b/launcher/modplatform/ftb/FTBPackInstallTask.cpp index b08357953..006b98238 100644 --- a/launcher/modplatform/ftb/FTBPackInstallTask.cpp +++ b/launcher/modplatform/ftb/FTBPackInstallTask.cpp @@ -38,6 +38,8 @@ #include "FTBPackInstallTask.h" +#include + #include "FileSystem.h" #include "Json.h" #include "minecraft/MinecraftInstance.h" @@ -59,15 +61,18 @@ PackInstallTask::PackInstallTask(Modpack pack, QString version, QWidget* parent) bool PackInstallTask::abort() { - if (!canAbort()) + if (!canAbort()) { return false; + } bool aborted = true; - if (m_net_job) + if (m_net_job) { aborted &= m_net_job->abort(); - if (m_modIdResolverTask) + } + if (m_modIdResolverTask) { aborted &= m_modIdResolverTask->abort(); + } return aborted ? InstanceTask::abort() : false; } @@ -78,15 +83,15 @@ void PackInstallTask::executeTask() setAbortable(false); // Find pack version - auto version_it = std::find_if(m_pack.versions.constBegin(), m_pack.versions.constEnd(), - [this](const FTB::VersionInfo& a) { return a.name == m_versionName; }); + auto versionIt = std::find_if(m_pack.versions.constBegin(), m_pack.versions.constEnd(), + [this](const FTB::VersionInfo& a) { return a.name == m_versionName; }); - if (version_it == m_pack.versions.constEnd()) { + if (versionIt == m_pack.versions.constEnd()) { emitFailed(tr("Failed to find pack version %1").arg(m_versionName)); return; } - auto version = *version_it; + const auto& version = *versionIt; auto netJob = makeShared("FTB::VersionFetch", APPLICATION->network()); @@ -112,10 +117,10 @@ void PackInstallTask::onManifestDownloadSucceeded(QByteArray* responsePtr) QByteArray response = std::move(*responsePtr); 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 FTB at " << parse_error.offset << " reason: " << parse_error.errorString(); + QJsonParseError parseError{}; + QJsonDocument const doc = QJsonDocument::fromJson(response, &parseError); + if (parseError.error != QJsonParseError::NoError) { + qWarning() << "Error while parsing JSON response from FTB at " << parseError.offset << " reason: " << parseError.errorString(); qWarning() << response; return; } @@ -179,24 +184,25 @@ void PackInstallTask::onResolveModsSucceeded() Flame::Manifest results = m_modIdResolverTask->getResults(); for (int index = 0; index < m_fileIds.size(); index++) { - const auto file_id = m_fileIds.at(index); - if (file_id < 0) + const auto fileId = m_fileIds.at(index); + if (fileId < 0) { continue; + } - Flame::File resultsFile = results.files[file_id]; + Flame::File const resultsFile = results.files.value(fileId); VersionFile& localFile = m_version.files[index]; // First check for blocked mods if (resultsFile.version.downloadUrl.isEmpty()) { - BlockedMod blocked_mod; - blocked_mod.name = resultsFile.version.fileName; - blocked_mod.websiteUrl = QString("%1/download/%2").arg(resultsFile.pack.websiteUrl, QString::number(resultsFile.fileId)); - blocked_mod.hash = resultsFile.version.hash; - blocked_mod.matched = false; - blocked_mod.localPath = ""; - blocked_mod.targetFolder = resultsFile.targetFolder; + BlockedMod blockedMod; + blockedMod.name = resultsFile.version.fileName; + blockedMod.websiteUrl = QString("%1/download/%2").arg(resultsFile.pack.websiteUrl, QString::number(resultsFile.fileId)); + blockedMod.hash = resultsFile.version.hash; + blockedMod.matched = false; + blockedMod.localPath = ""; + blockedMod.targetFolder = resultsFile.targetFolder; - m_blockedMods.append(blocked_mod); + m_blockedMods.append(blockedMod); anyBlocked = true; } else { @@ -209,14 +215,14 @@ void PackInstallTask::onResolveModsSucceeded() if (anyBlocked) { qDebug() << "Blocked files found, displaying file list"; - BlockedModsDialog message_dialog(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."), - m_blockedMods); + BlockedModsDialog messageDialog(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."), + m_blockedMods); - message_dialog.setModal(true); + messageDialog.setModal(true); - if (message_dialog.exec() == QDialog::Accepted) { + if (messageDialog.exec() == QDialog::Accepted) { qDebug() << "Post dialog blocked mods list: " << m_blockedMods; createInstance(); } else { @@ -239,19 +245,20 @@ void PackInstallTask::createInstance() auto instanceSettings = std::make_unique(instanceConfigPath); m_instance = std::make_unique(m_globalSettings, std::move(instanceSettings), m_stagingPath); - auto components = m_instance->getPackProfile(); + auto* components = m_instance->getPackProfile(); components->buildingFromScratch(); - for (auto target : m_version.targets) { + for (const 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") + for (const auto& target : m_version.targets) { + if (target.type != "modloader") { continue; + } if (target.name == "forge") { components->setComponentVersion("net.minecraftforge", target.version); @@ -299,13 +306,14 @@ void PackInstallTask::downloadPack() auto jobPtr = makeShared(tr("Mod download"), APPLICATION->network()); for (const auto& file : m_version.files) { - if (file.serverOnly || file.url.isEmpty()) + if (file.serverOnly || file.url.isEmpty()) { continue; + } auto path = FS::PathCombine(m_stagingPath, ".minecraft", file.path, file.name); qDebug() << "Will try to download" << file.url << "to" << path; - QFileInfo file_info(file.name); + QFileInfo const fileInfo(file.name); auto dl = Net::Download::makeFile(file.url, path); if (!file.sha1.isEmpty()) { @@ -339,21 +347,21 @@ void PackInstallTask::onModDownloadSucceeded() void PackInstallTask::onManifestDownloadFailed(QString reason) { m_net_job.reset(); - emitFailed(reason); + emitFailed(std::move(reason)); } void PackInstallTask::onResolveModsFailed(QString reason) { m_net_job.reset(); - emitFailed(reason); + emitFailed(std::move(reason)); } void PackInstallTask::onCreateInstanceFailed(QString reason) { - emitFailed(reason); + emitFailed(std::move(reason)); } void PackInstallTask::onModDownloadFailed(QString reason) { m_net_job.reset(); - emitFailed(reason); + emitFailed(std::move(reason)); } /// @brief copy the matched blocked mods to the instance staging area @@ -362,7 +370,7 @@ void PackInstallTask::copyBlockedMods() setStatus(tr("Copying Blocked Mods...")); setAbortable(false); int i = 0; - int total = m_blockedMods.length(); + auto total = m_blockedMods.length(); setProgress(i, total); for (const auto& mod : m_blockedMods) { if (!mod.matched) { @@ -370,14 +378,14 @@ void PackInstallTask::copyBlockedMods() continue; } - auto dest_path = FS::PathCombine(m_stagingPath, ".minecraft", mod.targetFolder, mod.name); + auto destPath = FS::PathCombine(m_stagingPath, ".minecraft", mod.targetFolder, mod.name); setStatus(tr("Copying Blocked Mods (%1 out of %2 are done)").arg(QString::number(i), QString::number(total))); - qDebug() << "Will try to copy" << mod.localPath << "to" << dest_path; + qDebug() << "Will try to copy" << mod.localPath << "to" << destPath; - if (!FS::copy(mod.localPath, dest_path)()) { - qDebug() << "Copy of" << mod.localPath << "to" << dest_path << "Failed"; + if (!FS::copy(mod.localPath, destPath)()) { + qDebug() << "Copy of" << mod.localPath << "to" << destPath << "Failed"; } i++; diff --git a/launcher/modplatform/import_ftb/PackInstallTask.cpp b/launcher/modplatform/import_ftb/PackInstallTask.cpp index f7d92f7c3..75fef6701 100644 --- a/launcher/modplatform/import_ftb/PackInstallTask.cpp +++ b/launcher/modplatform/import_ftb/PackInstallTask.cpp @@ -20,11 +20,9 @@ #include -#include "BaseInstance.h" #include "FileSystem.h" #include "minecraft/MinecraftInstance.h" #include "minecraft/PackProfile.h" -#include "modplatform/ResourceAPI.h" #include "modplatform/import_ftb/PackHelpers.h" #include "settings/INISettingsObject.h" @@ -55,7 +53,7 @@ void PackInstallTask::copySettings() std::make_unique(m_globalSettings, std::make_unique(instanceConfigPath), m_stagingPath); { - SettingsObject::Lock lock(m_instance->settings()); + SettingsObject::Lock const lock(m_instance->settings()); m_instance->settings()->set("InstanceType", "OneSix"); m_instance->settings()->set("totalTimePlayed", m_pack.totalPlayTime / 1000); diff --git a/launcher/modplatform/import_ftb/PackInstallTask.h b/launcher/modplatform/import_ftb/PackInstallTask.h index fe1d82059..f9a771a7d 100644 --- a/launcher/modplatform/import_ftb/PackInstallTask.h +++ b/launcher/modplatform/import_ftb/PackInstallTask.h @@ -21,9 +21,11 @@ #include #include +#include +#include #include "InstanceTask.h" #include "PackHelpers.h" -#include +#include "minecraft/MinecraftInstance.h" namespace FTBImportAPP { @@ -31,11 +33,11 @@ class PackInstallTask : public InstanceTask { Q_OBJECT public: - explicit PackInstallTask(const Modpack& pack) : m_pack(pack) {} - virtual ~PackInstallTask() = default; + explicit PackInstallTask(Modpack pack) : m_pack(std::move(pack)) {} + ~PackInstallTask() override = default; protected: - virtual void executeTask() override; + void executeTask() override; private slots: void copySettings(); diff --git a/launcher/modplatform/legacy_ftb/PackInstallTask.cpp b/launcher/modplatform/legacy_ftb/PackInstallTask.cpp index d4d009865..f88071dd2 100644 --- a/launcher/modplatform/legacy_ftb/PackInstallTask.cpp +++ b/launcher/modplatform/legacy_ftb/PackInstallTask.cpp @@ -36,6 +36,7 @@ #include "PackInstallTask.h" #include +#include #include "BaseInstance.h" #include "FileSystem.h" @@ -52,12 +53,9 @@ namespace LegacyFTB { -PackInstallTask::PackInstallTask(QNetworkAccessManager* network, const Modpack& pack, QString version) -{ - m_pack = pack; - m_version = version; - m_network = network; -} +PackInstallTask::PackInstallTask(QNetworkAccessManager* network, Modpack pack, QString version) + : m_network(network), m_pack(std::move(pack)), m_version(std::move(version)) +{} void PackInstallTask::executeTask() { @@ -73,22 +71,22 @@ void PackInstallTask::downloadPack() auto path = QString("%1/%2/%3").arg(m_pack.dir, m_version.replace(".", "_"), m_pack.file); auto entry = APPLICATION->metacache()->resolveEntry("FTBPacks", path); entry->setStale(true); - archivePath = entry->getFullPath(); - netJobContainer.reset(new NetJob("Download FTB Pack", m_network)); + m_archivePath = entry->getFullPath(); + m_netJobContainer.reset(new NetJob("Download FTB Pack", m_network)); QString url; if (m_pack.type == PackType::Private) { url = QString(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "privatepacks/%1").arg(path); } else { url = QString(BuildConfig.LEGACY_FTB_CDN_BASE_URL + "modpacks/%1").arg(path); } - netJobContainer->addNetAction(Net::ApiDownload::makeCached(url, entry)); + m_netJobContainer->addNetAction(Net::ApiDownload::makeCached(url, entry)); - connect(netJobContainer.get(), &NetJob::succeeded, this, &PackInstallTask::unzip); - connect(netJobContainer.get(), &NetJob::failed, this, &PackInstallTask::emitFailed); - connect(netJobContainer.get(), &NetJob::stepProgress, this, &PackInstallTask::propagateStepProgress); - connect(netJobContainer.get(), &NetJob::aborted, this, &PackInstallTask::emitAborted); + connect(m_netJobContainer.get(), &NetJob::succeeded, this, &PackInstallTask::unzip); + connect(m_netJobContainer.get(), &NetJob::failed, this, &PackInstallTask::emitFailed); + connect(m_netJobContainer.get(), &NetJob::stepProgress, this, &PackInstallTask::propagateStepProgress); + connect(m_netJobContainer.get(), &NetJob::aborted, this, &PackInstallTask::emitAborted); - netJobContainer->start(); + m_netJobContainer->start(); setAbortable(true); progress(1, 4); @@ -102,7 +100,7 @@ void PackInstallTask::unzip() QDir extractDir(m_stagingPath); - m_extractFuture = QtConcurrent::run(QThreadPool::globalInstance(), QOverload::of(MMCZip::extractDir), archivePath, + m_extractFuture = QtConcurrent::run(QThreadPool::globalInstance(), QOverload::of(MMCZip::extractDir), m_archivePath, extractDir.absolutePath() + "/unzip"); connect(&m_extractFutureWatcher, &QFutureWatcher::finished, this, &PackInstallTask::onUnzipFinished); connect(&m_extractFutureWatcher, &QFutureWatcher::canceled, this, &PackInstallTask::onUnzipCanceled); @@ -136,9 +134,9 @@ void PackInstallTask::install() m_instance = std::make_unique(m_globalSettings, std::make_unique(instanceConfigPath), m_stagingPath); { - SettingsObject::Lock lock(m_instance->settings()); + SettingsObject::Lock const lock(m_instance->settings()); - auto components = m_instance->getPackProfile(); + auto* components = m_instance->getPackProfile(); components->buildingFromScratch(); components->setComponentVersion("net.minecraft", m_pack.mcVersion, true); @@ -178,7 +176,7 @@ void PackInstallTask::install() qDebug() << "Found jarmods, installing..."; QStringList jarmods; - for (auto info : jarmodDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files)) { + for (const auto& info : jarmodDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files)) { qDebug() << "Jarmod:" << info.fileName(); jarmods.push_back(info.absoluteFilePath()); } @@ -216,7 +214,7 @@ bool PackInstallTask::abort() return false; } - netJobContainer->abort(); + m_netJobContainer->abort(); return InstanceTask::abort(); } diff --git a/launcher/modplatform/legacy_ftb/PackInstallTask.h b/launcher/modplatform/legacy_ftb/PackInstallTask.h index 04998998f..c13e052e3 100644 --- a/launcher/modplatform/legacy_ftb/PackInstallTask.h +++ b/launcher/modplatform/legacy_ftb/PackInstallTask.h @@ -1,13 +1,11 @@ #pragma once #include "InstanceTask.h" #include "PackHelpers.h" -#include "meta/Index.h" -#include "meta/Version.h" -#include "meta/VersionList.h" +#include "minecraft/MinecraftInstance.h" #include "net/NetJob.h" -#include #include +#include namespace LegacyFTB { @@ -15,15 +13,15 @@ class PackInstallTask : public InstanceTask { Q_OBJECT public: - explicit PackInstallTask(QNetworkAccessManager* network, const Modpack& pack, QString version); - virtual ~PackInstallTask() {} + explicit PackInstallTask(QNetworkAccessManager* network, Modpack pack, QString version); + ~PackInstallTask() override = default; bool canAbort() const override { return true; } bool abort() override; protected: //! Entry point for tasks. - virtual void executeTask() override; + void executeTask() override; private: void downloadPack(); @@ -37,11 +35,11 @@ class PackInstallTask : public InstanceTask { private: /* data */ QNetworkAccessManager* m_network; - bool abortable = false; + bool m_abortable = false; QFuture> m_extractFuture; QFutureWatcher> m_extractFutureWatcher; - NetJob::Ptr netJobContainer; - QString archivePath; + NetJob::Ptr m_netJobContainer; + QString m_archivePath; std::unique_ptr m_instance; diff --git a/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp b/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp index 4ac044f69..f7a4888ef 100644 --- a/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp +++ b/launcher/modplatform/modrinth/ModrinthInstanceCreationTask.cpp @@ -262,7 +262,7 @@ void ModrinthCreationTask::createInstance() ModDetails d; d.mod_id = filePath; mod->setDetails(d); - m_resources[file.hash.toHex()] = mod; + m_resources.insert(file.hash.toHex(), mod); } if (file.downloads.empty()) { emitFailed(tr("The file '%1' is missing a download link. This is invalid in the pack format.").arg(fileName)); @@ -324,9 +324,9 @@ bool ModrinthCreationTask::parseManifest(const QString& indexPath, std::vector(obj, "files", "modrinth.index.json"); @@ -436,7 +436,7 @@ bool ModrinthCreationTask::parseManifest(const QString& indexPath, std::vector(m_resources, folder, ModPlatform::ResourceProvider::MODRINTH); connect(ensureMetadataTask.get(), &Task::succeeded, this, &ModrinthCreationTask::finishInstall); connect(ensureMetadataTask.get(), &Task::failed, this, &ModrinthCreationTask::emitFailed); @@ -474,7 +474,7 @@ void ModrinthCreationTask::finishInstall() // Update information of the already installed instance, if any. if (m_oldInstance) { setAbortable(false); - auto* inst = m_oldInstance.value(); + auto* inst = *m_oldInstance; // Only change the name if it didn't use a custom name, so that the previous custom name // is preserved, but if we're using the original one, we update the version string. @@ -485,7 +485,7 @@ void ModrinthCreationTask::finishInstall() } } - setManagedPack(m_oldInstance.value()); + setManagedPack(*m_oldInstance); } if (shouldOverride()) { diff --git a/launcher/ui/pages/instance/ManagedPackPage.cpp b/launcher/ui/pages/instance/ManagedPackPage.cpp index 01ad9837d..d371e4791 100644 --- a/launcher/ui/pages/instance/ManagedPackPage.cpp +++ b/launcher/ui/pages/instance/ManagedPackPage.cpp @@ -59,7 +59,7 @@ class NoBigComboBoxStyle : public QProxyStyle { static QHash s_singleton_instances = {}; static std::mutex s_singleton_instances_mutex; - std::lock_guard lock(s_singleton_instances_mutex); + std::scoped_lock const lock(s_singleton_instances_mutex); auto instIter = s_singleton_instances.constFind(style); NoBigComboBoxStyle* inst = nullptr; if (instIter == s_singleton_instances.constEnd() || *instIter == nullptr) { @@ -205,7 +205,7 @@ bool ManagedPackPage::runUpdateTask(InstanceTask* task) { Q_ASSERT(task); - unique_qobject_ptr wrappedTask(APPLICATION->instances()->wrapInstanceTask(task)); + unique_qobject_ptr const wrappedTask(APPLICATION->instances()->wrapInstanceTask(task)); connect(wrappedTask.get(), &Task::failed, [this](const QString& reason) { CustomMessageBox::selectable(this, tr("Error"), reason, QMessageBox::Critical)->show(); });