diff --git a/launcher/meta/VersionList.cpp b/launcher/meta/VersionList.cpp index 8bc326839..28a42d28d 100644 --- a/launcher/meta/VersionList.cpp +++ b/launcher/meta/VersionList.cpp @@ -254,8 +254,9 @@ void VersionList::setupAddedVersion(const int row, const Version::Ptr& version) connect(version.get(), &Version::requiresChanged, this, [this, row]() { emit dataChanged(index(row), index(row), QVector() << RequiresRole); }); - connect(version.get(), &Version::timeChanged, this, - [this, row]() { emit dataChanged(index(row), index(row), { TimeRole, SortRole }); }); + connect(version.get(), &Version::timeChanged, this, [this, row]() { + emit dataChanged(index(row), index(row), { TimeRole, SortRole }); + }); connect(version.get(), &Version::typeChanged, this, [this, row]() { emit dataChanged(index(row), index(row), { TypeRole }); }); } diff --git a/launcher/meta/VersionList.h b/launcher/meta/VersionList.h index 2e46a79f0..eb79e96f1 100644 --- a/launcher/meta/VersionList.h +++ b/launcher/meta/VersionList.h @@ -46,7 +46,6 @@ class VersionList : public BaseVersionList, public BaseEntity { Version::Ptr getRecommendedForParent(const QString& uid, const QString& version); Version::Ptr getLatestForParent(const QString& uid, const QString& version); - QVariant data(const QModelIndex& index, int role) const override; RoleList providesRoles() const override; QHash roleNames() const override; diff --git a/launcher/minecraft/Component.cpp b/launcher/minecraft/Component.cpp index 175e88d08..6ea9ee60b 100644 --- a/launcher/minecraft/Component.cpp +++ b/launcher/minecraft/Component.cpp @@ -403,8 +403,8 @@ void Component::updateCachedData() } } -void Component::waitLoadMeta() { - +void Component::waitLoadMeta() +{ if (!m_loaded) { if (!m_metaVersion || !m_metaVersion->isLoaded()) { // wait for the loaded version from meta @@ -415,7 +415,8 @@ void Component::waitLoadMeta() { } } -QDebug operator<<(QDebug d, const Component& comp) { +QDebug operator<<(QDebug d, const Component& comp) +{ d << "Component(" << comp.m_uid << " : " << comp.m_cachedVersion << ")"; return d; } diff --git a/launcher/minecraft/Component.h b/launcher/minecraft/Component.h index 581a3db95..67d79e231 100644 --- a/launcher/minecraft/Component.h +++ b/launcher/minecraft/Component.h @@ -64,7 +64,7 @@ class Component : public QObject, public ProblemProvider { bool revert(); void updateCachedData(); - + void waitLoadMeta(); signals: diff --git a/launcher/minecraft/ComponentUpdateTask.cpp b/launcher/minecraft/ComponentUpdateTask.cpp index 7bdc11400..dc59d2dc9 100644 --- a/launcher/minecraft/ComponentUpdateTask.cpp +++ b/launcher/minecraft/ComponentUpdateTask.cpp @@ -178,7 +178,8 @@ void ComponentUpdateTask::loadComponents() } result = composeLoadResult(result, singleResult); if (loadTask) { - qCDebug(instanceProfileResolveC) << d->m_profile->d->m_instance->name() << "|" << "Remote loading is being run for" << component->getName(); + qCDebug(instanceProfileResolveC) << d->m_profile->d->m_instance->name() << "|" + << "Remote loading is being run for" << component->getName(); connect(loadTask.get(), &Task::succeeded, this, [this, taskIndex]() { remoteLoadSucceeded(taskIndex); }); connect(loadTask.get(), &Task::failed, this, [this, taskIndex](const QString& error) { remoteLoadFailed(taskIndex, error); }); connect(loadTask.get(), &Task::aborted, this, [this, taskIndex]() { remoteLoadFailed(taskIndex, tr("Aborted")); }); @@ -273,8 +274,8 @@ static bool gatherRequirementsFromComponents(const ComponentContainer& input, Re output.erase(componenRequireEx); output.insert(result.outcome); } else { - qCCritical(instanceProfileResolveC) << "Conflicting requirements:" << componentRequire.uid << "versions:" << componentRequire.equalsVersion - << ";" << (*found).equalsVersion; + qCCritical(instanceProfileResolveC) << "Conflicting requirements:" << componentRequire.uid + << "versions:" << componentRequire.equalsVersion << ";" << (*found).equalsVersion; } succeeded &= result.ok; } else { @@ -440,7 +441,8 @@ void ComponentUpdateTask::resolveDependencies(bool checkOnly) auto component = makeShared(d->m_profile, add.uid); if (!add.equalsVersion.isEmpty()) { // exact version - qCDebug(instanceProfileResolveC) << "Adding" << add.uid << "version" << add.equalsVersion << "at position" << add.indexOfFirstDependee; + qCDebug(instanceProfileResolveC) + << "Adding" << add.uid << "version" << add.equalsVersion << "at position" << add.indexOfFirstDependee; component->m_version = add.equalsVersion; } else { // version needs to be decided diff --git a/launcher/minecraft/PackProfile.cpp b/launcher/minecraft/PackProfile.cpp index 09a2ac0cb..ce57288f6 100644 --- a/launcher/minecraft/PackProfile.cpp +++ b/launcher/minecraft/PackProfile.cpp @@ -247,12 +247,14 @@ void PackProfile::buildingFromScratch() void PackProfile::scheduleSave() { if (!d->loaded) { - qDebug() << d->m_instance->name() << "|" << "Component list should never save if it didn't successfully load"; + qDebug() << d->m_instance->name() << "|" + << "Component list should never save if it didn't successfully load"; return; } if (!d->dirty) { d->dirty = true; - qDebug() << d->m_instance->name() << "|" << "Component list save is scheduled"; + qDebug() << d->m_instance->name() << "|" + << "Component list save is scheduled"; } d->m_saveTimer.start(); } @@ -279,7 +281,8 @@ QString PackProfile::patchFilePathForUid(const QString& uid) const void PackProfile::save_internal() { - qDebug() << d->m_instance->name() << "|" << "Component list save performed now"; + qDebug() << d->m_instance->name() << "|" + << "Component list save performed now"; auto filename = componentsFilePath(); savePackProfile(filename, d->components); d->dirty = false; @@ -292,7 +295,8 @@ bool PackProfile::load() // load the new component list and swap it with the current one... ComponentContainer newComponents; if (!loadPackProfile(this, filename, patchesPattern(), newComponents)) { - qCritical() << d->m_instance->name() << "|" << "Failed to load the component config"; + qCritical() << d->m_instance->name() << "|" + << "Failed to load the component config"; return false; } else { // FIXME: actually use fine-grained updates, not this... @@ -305,7 +309,8 @@ bool PackProfile::load() d->componentIndex.clear(); for (auto component : newComponents) { if (d->componentIndex.contains(component->m_uid)) { - qWarning() << d->m_instance->name() << "|" << "Ignoring duplicate component entry" << component->m_uid; + qWarning() << d->m_instance->name() << "|" + << "Ignoring duplicate component entry" << component->m_uid; continue; } connect(component.get(), &Component::dataChanged, this, &PackProfile::componentDataChanged); @@ -353,14 +358,17 @@ void PackProfile::resolve(Net::Mode netmode) void PackProfile::updateSucceeded() { - qCDebug(instanceProfileC) << d->m_instance->name() << "|" << "Component list update/resolve task succeeded"; + qCDebug(instanceProfileC) << d->m_instance->name() << "|" + << "Component list update/resolve task succeeded"; d->m_updateTask.reset(); invalidateLaunchProfile(); } void PackProfile::updateFailed(const QString& error) { - qCDebug(instanceProfileC) << d->m_instance->name() << "|" << "Component list update/resolve task failed " << "Reason:" << error; + qCDebug(instanceProfileC) << d->m_instance->name() << "|" + << "Component list update/resolve task failed " + << "Reason:" << error; d->m_updateTask.reset(); invalidateLaunchProfile(); } @@ -376,11 +384,13 @@ void PackProfile::insertComponent(size_t index, ComponentPtr component) { auto id = component->getID(); if (id.isEmpty()) { - qCWarning(instanceProfileC) << d->m_instance->name() << "|" << "Attempt to add a component with empty ID!"; + qCWarning(instanceProfileC) << d->m_instance->name() << "|" + << "Attempt to add a component with empty ID!"; return; } if (d->componentIndex.contains(id)) { - qCWarning(instanceProfileC) << d->m_instance->name() << "|" << "Attempt to add a component that is already present!"; + qCWarning(instanceProfileC) << d->m_instance->name() << "|" + << "Attempt to add a component that is already present!"; return; } beginInsertRows(QModelIndex(), static_cast(index), static_cast(index)); @@ -395,7 +405,8 @@ void PackProfile::componentDataChanged() { auto objPtr = qobject_cast(sender()); if (!objPtr) { - qCWarning(instanceProfileC) << d->m_instance->name() << "|" << "PackProfile got dataChanged signal from a non-Component!"; + qCWarning(instanceProfileC) << d->m_instance->name() << "|" + << "PackProfile got dataChanged signal from a non-Component!"; return; } if (objPtr->getID() == "net.minecraft") { @@ -419,12 +430,14 @@ bool PackProfile::remove(const int index) { auto patch = getComponent(index); if (!patch->isRemovable()) { - qCWarning(instanceProfileC) << d->m_instance->name() << "|" << "Patch" << patch->getID() << "is non-removable"; + qCWarning(instanceProfileC) << d->m_instance->name() << "|" + << "Patch" << patch->getID() << "is non-removable"; return false; } if (!removeComponent_internal(patch)) { - qCCritical(instanceProfileC) << d->m_instance->name() << "|" << "Patch" << patch->getID() << "could not be removed"; + qCCritical(instanceProfileC) << d->m_instance->name() << "|" + << "Patch" << patch->getID() << "could not be removed"; return false; } @@ -453,11 +466,13 @@ bool PackProfile::customize(int index) { auto patch = getComponent(index); if (!patch->isCustomizable()) { - qCDebug(instanceProfileC) << d->m_instance->name() << "|" << "Patch" << patch->getID() << "is not customizable"; + qCDebug(instanceProfileC) << d->m_instance->name() << "|" + << "Patch" << patch->getID() << "is not customizable"; return false; } if (!patch->customize()) { - qCCritical(instanceProfileC) << d->m_instance->name() << "|" << "Patch" << patch->getID() << "could not be customized"; + qCCritical(instanceProfileC) << d->m_instance->name() << "|" + << "Patch" << patch->getID() << "could not be customized"; return false; } invalidateLaunchProfile(); @@ -469,11 +484,13 @@ bool PackProfile::revertToBase(int index) { auto patch = getComponent(index); if (!patch->isRevertible()) { - qCDebug(instanceProfileC) << d->m_instance->name() << "|" << "Patch" << patch->getID() << "is not revertible"; + qCDebug(instanceProfileC) << d->m_instance->name() << "|" + << "Patch" << patch->getID() << "is not revertible"; return false; } if (!patch->revert()) { - qCCritical(instanceProfileC) << d->m_instance->name() << "|" << "Patch" << patch->getID() << "could not be reverted"; + qCCritical(instanceProfileC) << d->m_instance->name() << "|" + << "Patch" << patch->getID() << "could not be reverted"; return false; } invalidateLaunchProfile(); @@ -686,8 +703,8 @@ bool PackProfile::installComponents(QStringList selectedFiles) const QString target = FS::PathCombine(patchDir, versionFile->uid + ".json"); if (!QFile::copy(source, target)) { - qCWarning(instanceProfileC) << d->m_instance->name() << "|" << "Component" << source << "could not be copied to target" - << target; + qCWarning(instanceProfileC) << d->m_instance->name() << "|" + << "Component" << source << "could not be copied to target" << target; result = false; continue; } @@ -720,8 +737,8 @@ bool PackProfile::installEmpty(const QString& uid, const QString& name) QString patchFileName = FS::PathCombine(patchDir, uid + ".json"); QFile file(patchFileName); if (!file.open(QFile::WriteOnly)) { - qCCritical(instanceProfileC) << d->m_instance->name() << "|" << "Error opening" << file.fileName() - << "for reading:" << file.errorString(); + qCCritical(instanceProfileC) << d->m_instance->name() << "|" + << "Error opening" << file.fileName() << "for reading:" << file.errorString(); return false; } file.write(OneSixVersionFormat::versionFileToJson(f).toJson()); @@ -741,8 +758,8 @@ bool PackProfile::removeComponent_internal(ComponentPtr patch) if (fileName.size()) { QFile patchFile(fileName); if (patchFile.exists() && !patchFile.remove()) { - qCCritical(instanceProfileC) << d->m_instance->name() << "|" << "File" << fileName - << "could not be removed because:" << patchFile.errorString(); + qCCritical(instanceProfileC) << d->m_instance->name() << "|" + << "File" << fileName << "could not be removed because:" << patchFile.errorString(); return false; } } @@ -758,8 +775,8 @@ bool PackProfile::removeComponent_internal(ComponentPtr patch) if (finfo.exists()) { QFile jarModFile(jar[0]); if (!jarModFile.remove()) { - qCCritical(instanceProfileC) << d->m_instance->name() << "|" << "File" << jar[0] - << "could not be removed because:" << jarModFile.errorString(); + qCCritical(instanceProfileC) << d->m_instance->name() << "|" + << "File" << jar[0] << "could not be removed because:" << jarModFile.errorString(); return false; } return true; @@ -816,8 +833,8 @@ bool PackProfile::installJarMods_internal(QStringList filepaths) QFile file(patchFileName); if (!file.open(QFile::WriteOnly)) { - qCCritical(instanceProfileC) << d->m_instance->name() << "|" << "Error opening" << file.fileName() - << "for reading:" << file.errorString(); + qCCritical(instanceProfileC) << d->m_instance->name() << "|" + << "Error opening" << file.fileName() << "for reading:" << file.errorString(); return false; } file.write(OneSixVersionFormat::versionFileToJson(f).toJson()); @@ -871,8 +888,8 @@ bool PackProfile::installCustomJar_internal(QString filepath) QFile file(patchFileName); if (!file.open(QFile::WriteOnly)) { - qCCritical(instanceProfileC) << d->m_instance->name() << "|" << "Error opening" << file.fileName() - << "for reading:" << file.errorString(); + qCCritical(instanceProfileC) << d->m_instance->name() << "|" + << "Error opening" << file.fileName() << "for reading:" << file.errorString(); return false; } file.write(OneSixVersionFormat::versionFileToJson(f).toJson()); @@ -927,8 +944,8 @@ bool PackProfile::installAgents_internal(QStringList filepaths) QFile patchFile(FS::PathCombine(patchDir, targetId + ".json")); if (!patchFile.open(QFile::WriteOnly)) { - qCCritical(instanceProfileC) << d->m_instance->name() << "|" << "Error opening" << patchFile.fileName() - << "for reading:" << patchFile.errorString(); + qCCritical(instanceProfileC) << d->m_instance->name() << "|" + << "Error opening" << patchFile.fileName() << "for reading:" << patchFile.errorString(); return false; } @@ -950,13 +967,15 @@ std::shared_ptr PackProfile::getProfile() const try { auto profile = std::make_shared(); for (auto file : d->components) { - qCDebug(instanceProfileC) << d->m_instance->name() << "|" << "Applying" << file->getID() + qCDebug(instanceProfileC) << d->m_instance->name() << "|" + << "Applying" << file->getID() << (file->getProblemSeverity() == ProblemSeverity::Error ? "ERROR" : "GOOD"); file->applyTo(profile.get()); } d->m_profile = profile; } catch (const Exception& error) { - qCWarning(instanceProfileC) << d->m_instance->name() << "|" << "Couldn't apply profile patches because: " << error.cause(); + qCWarning(instanceProfileC) << d->m_instance->name() << "|" + << "Couldn't apply profile patches because: " << error.cause(); } } return d->m_profile; @@ -986,9 +1005,9 @@ bool PackProfile::setComponentVersion(const QString& uid, const QString& version if (versionList) { auto recommended = versionList->getRecommendedForParent(uid, version); if (recommended) { - qCDebug(instanceProfileC) - << d->m_instance->name() << "|" << "setting updated loader to recommended version: " << comp->getID() - << " = " << recommended->version(); + qCDebug(instanceProfileC) << d->m_instance->name() << "|" + << "setting updated loader to recommended version: " << comp->getID() << " = " + << recommended->version(); comp->setVersion(recommended->version()); } else { auto latest = versionList->getLatestForParent(uid, version); @@ -998,14 +1017,14 @@ bool PackProfile::setComponentVersion(const QString& uid, const QString& version << " = " << latest->version(); comp->setVersion(latest->version()); } else { - qCDebug(instanceProfileC) - << d->m_instance->name() << "|" << "no compatible version for" << comp->getID() << "removing"; + qCDebug(instanceProfileC) << d->m_instance->name() << "|" + << "no compatible version for" << comp->getID() << "removing"; remove(comp->getID()); } } } else { - qCDebug(instanceProfileC) - << d->m_instance->name() << "|" << "no version list in metadata index for" << comp->getID(); + qCDebug(instanceProfileC) << d->m_instance->name() << "|" + << "no version list in metadata index for" << comp->getID(); } } else { qCDebug(instanceProfileC) << d->m_instance->name() << "|" << comp->getID() << ":" << comp->getVersion() @@ -1038,8 +1057,8 @@ ComponentContainer PackProfile::collectTreeLinked(const QString& uid) { ComponentContainer linked; for (auto comp : d->components) { - qCDebug(instanceProfileC) << d->m_instance->name() << "|" << "scanning" << comp->getID() << ":" << comp->getVersion() - << "for tree link"; + qCDebug(instanceProfileC) << d->m_instance->name() << "|" + << "scanning" << comp->getID() << ":" << comp->getVersion() << "for tree link"; auto dep = std::find_if(comp->m_cachedRequires.cbegin(), comp->m_cachedRequires.cend(), [uid](const Meta::Require& req) -> bool { return req.uid == uid; }); if (dep != comp->m_cachedRequires.cend()) {