From 7956e6f04e32448b0043a49ff08873e117ba0a0b Mon Sep 17 00:00:00 2001 From: flow Date: Tue, 1 Nov 2022 19:48:26 -0300 Subject: [PATCH] fix: don't use forward-declared Ptr types in meta/ This would cause ODR violations when those headers were included in other places that also included stuff like "Version.h" (note the "meta/Version.h"), which can cause problems, especially in LTO. Signed-off-by: flow --- launcher/BaseInstaller.h | 5 +-- launcher/BaseVersion.h | 5 ++- launcher/BaseVersionList.cpp | 10 +++--- launcher/BaseVersionList.h | 8 ++--- launcher/java/JavaInstallList.cpp | 10 +++--- launcher/java/JavaInstallList.h | 6 ++-- launcher/meta/Index.cpp | 16 +++++----- launcher/meta/Index.h | 17 +++++----- launcher/meta/JsonFormat.cpp | 18 +++++------ launcher/meta/Version.cpp | 4 +-- launcher/meta/Version.h | 11 ++++--- launcher/meta/VersionList.cpp | 30 ++++++++--------- launcher/meta/VersionList.h | 32 ++++++++++--------- .../minecraft/VanillaInstanceCreationTask.cpp | 2 +- .../minecraft/VanillaInstanceCreationTask.h | 8 ++--- .../atlauncher/ATLPackInstallTask.cpp | 4 +-- .../atlauncher/ATLPackInstallTask.h | 6 ++-- launcher/ui/dialogs/VersionSelectDialog.cpp | 2 +- launcher/ui/dialogs/VersionSelectDialog.h | 2 +- launcher/ui/pages/modplatform/VanillaPage.cpp | 8 ++--- launcher/ui/pages/modplatform/VanillaPage.h | 12 +++---- .../AtlUserInteractionSupportImpl.cpp | 2 +- .../AtlUserInteractionSupportImpl.h | 2 +- launcher/ui/widgets/JavaSettingsWidget.cpp | 2 +- launcher/ui/widgets/JavaSettingsWidget.h | 2 +- launcher/ui/widgets/ModFilterWidget.h | 4 +-- launcher/ui/widgets/VersionSelectWidget.cpp | 6 ++-- launcher/ui/widgets/VersionSelectWidget.h | 4 +-- 28 files changed, 120 insertions(+), 118 deletions(-) diff --git a/launcher/BaseInstaller.h b/launcher/BaseInstaller.h index b2e6a14d..a1b80e93 100644 --- a/launcher/BaseInstaller.h +++ b/launcher/BaseInstaller.h @@ -17,13 +17,14 @@ #include +#include "BaseVersion.h" + class MinecraftInstance; class QDir; class QString; class QObject; class Task; class BaseVersion; -typedef std::shared_ptr BaseVersionPtr; class BaseInstaller { @@ -35,7 +36,7 @@ public: virtual bool add(MinecraftInstance *to); virtual bool remove(MinecraftInstance *from); - virtual Task *createInstallTask(MinecraftInstance *instance, BaseVersionPtr version, QObject *parent) = 0; + virtual Task *createInstallTask(MinecraftInstance *instance, BaseVersion::Ptr version, QObject *parent) = 0; protected: virtual QString id() const = 0; diff --git a/launcher/BaseVersion.h b/launcher/BaseVersion.h index b88105fb..ca0e4502 100644 --- a/launcher/BaseVersion.h +++ b/launcher/BaseVersion.h @@ -25,6 +25,7 @@ class BaseVersion { public: + using Ptr = std::shared_ptr; virtual ~BaseVersion() {} /*! * A string used to identify this version in config files. @@ -54,6 +55,4 @@ public: }; }; -typedef std::shared_ptr BaseVersionPtr; - -Q_DECLARE_METATYPE(BaseVersionPtr) +Q_DECLARE_METATYPE(BaseVersion::Ptr) diff --git a/launcher/BaseVersionList.cpp b/launcher/BaseVersionList.cpp index b4a7d6dd..4ed82612 100644 --- a/launcher/BaseVersionList.cpp +++ b/launcher/BaseVersionList.cpp @@ -40,20 +40,20 @@ BaseVersionList::BaseVersionList(QObject *parent) : QAbstractListModel(parent) { } -BaseVersionPtr BaseVersionList::findVersion(const QString &descriptor) +BaseVersion::Ptr BaseVersionList::findVersion(const QString &descriptor) { for (int i = 0; i < count(); i++) { if (at(i)->descriptor() == descriptor) return at(i); } - return BaseVersionPtr(); + return nullptr; } -BaseVersionPtr BaseVersionList::getRecommended() const +BaseVersion::Ptr BaseVersionList::getRecommended() const { if (count() <= 0) - return BaseVersionPtr(); + return nullptr; else return at(0); } @@ -66,7 +66,7 @@ QVariant BaseVersionList::data(const QModelIndex &index, int role) const if (index.row() > count()) return QVariant(); - BaseVersionPtr version = at(index.row()); + BaseVersion::Ptr version = at(index.row()); switch (role) { diff --git a/launcher/BaseVersionList.h b/launcher/BaseVersionList.h index 80a91e8f..31f29022 100644 --- a/launcher/BaseVersionList.h +++ b/launcher/BaseVersionList.h @@ -70,7 +70,7 @@ public: virtual bool isLoaded() = 0; //! Gets the version at the given index. - virtual const BaseVersionPtr at(int i) const = 0; + virtual const BaseVersion::Ptr at(int i) const = 0; //! Returns the number of versions in the list. virtual int count() const = 0; @@ -90,13 +90,13 @@ public: * \return A const pointer to the version with the given descriptor. NULL if * one doesn't exist. */ - virtual BaseVersionPtr findVersion(const QString &descriptor); + virtual BaseVersion::Ptr findVersion(const QString &descriptor); /*! * \brief Gets the recommended version from this list * If the list doesn't support recommended versions, this works exactly as getLatestStable */ - virtual BaseVersionPtr getRecommended() const; + virtual BaseVersion::Ptr getRecommended() const; /*! * Sorts the version list. @@ -117,5 +117,5 @@ slots: * then copies the versions and sets their parents correctly. * \param versions List of versions whose parents should be set. */ - virtual void updateListData(QList versions) = 0; + virtual void updateListData(QList versions) = 0; }; diff --git a/launcher/java/JavaInstallList.cpp b/launcher/java/JavaInstallList.cpp index 0249bd22..155c956a 100644 --- a/launcher/java/JavaInstallList.cpp +++ b/launcher/java/JavaInstallList.cpp @@ -73,7 +73,7 @@ void JavaInstallList::load() } } -const BaseVersionPtr JavaInstallList::at(int i) const +const BaseVersion::Ptr JavaInstallList::at(int i) const { return m_vlist.at(i); } @@ -122,7 +122,7 @@ BaseVersionList::RoleList JavaInstallList::providesRoles() const } -void JavaInstallList::updateListData(QList versions) +void JavaInstallList::updateListData(QList versions) { beginResetModel(); m_vlist = versions; @@ -137,7 +137,7 @@ void JavaInstallList::updateListData(QList versions) m_loadTask.reset(); } -bool sortJavas(BaseVersionPtr left, BaseVersionPtr right) +bool sortJavas(BaseVersion::Ptr left, BaseVersion::Ptr right) { auto rleft = std::dynamic_pointer_cast(right); auto rright = std::dynamic_pointer_cast(left); @@ -210,11 +210,11 @@ void JavaListLoadTask::javaCheckerFinished() } } - QList javas_bvp; + QList javas_bvp; for (auto java : candidates) { //qDebug() << java->id << java->arch << " at " << java->path; - BaseVersionPtr bp_java = std::dynamic_pointer_cast(java); + BaseVersion::Ptr bp_java = std::dynamic_pointer_cast(java); if (bp_java) { diff --git a/launcher/java/JavaInstallList.h b/launcher/java/JavaInstallList.h index 3c237edf..733dc7e1 100644 --- a/launcher/java/JavaInstallList.h +++ b/launcher/java/JavaInstallList.h @@ -42,7 +42,7 @@ public: Task::Ptr getLoadTask() override; bool isLoaded() override; - const BaseVersionPtr at(int i) const override; + const BaseVersion::Ptr at(int i) const override; int count() const override; void sortVersions() override; @@ -50,7 +50,7 @@ public: RoleList providesRoles() const override; public slots: - void updateListData(QList versions) override; + void updateListData(QList versions) override; protected: void load(); @@ -59,7 +59,7 @@ protected: protected: Status m_status = Status::NotDone; shared_qobject_ptr m_loadTask; - QList m_vlist; + QList m_vlist; }; class JavaListLoadTask : public Task diff --git a/launcher/meta/Index.cpp b/launcher/meta/Index.cpp index 6802470d..eec1b329 100644 --- a/launcher/meta/Index.cpp +++ b/launcher/meta/Index.cpp @@ -24,7 +24,7 @@ Index::Index(QObject *parent) : QAbstractListModel(parent) { } -Index::Index(const QVector &lists, QObject *parent) +Index::Index(const QVector &lists, QObject *parent) : QAbstractListModel(parent), m_lists(lists) { for (int i = 0; i < m_lists.size(); ++i) @@ -41,7 +41,7 @@ QVariant Index::data(const QModelIndex &index, int role) const return QVariant(); } - VersionListPtr list = m_lists.at(index.row()); + VersionList::Ptr list = m_lists.at(index.row()); switch (role) { case Qt::DisplayRole: @@ -81,9 +81,9 @@ bool Index::hasUid(const QString &uid) const return m_uids.contains(uid); } -VersionListPtr Index::get(const QString &uid) +VersionList::Ptr Index::get(const QString &uid) { - VersionListPtr out = m_uids.value(uid, nullptr); + VersionList::Ptr out = m_uids.value(uid, nullptr); if(!out) { out = std::make_shared(uid); @@ -92,7 +92,7 @@ VersionListPtr Index::get(const QString &uid) return out; } -VersionPtr Index::get(const QString &uid, const QString &version) +Version::Ptr Index::get(const QString &uid, const QString &version) { auto list = get(uid); return list->getVersion(version); @@ -105,7 +105,7 @@ void Index::parse(const QJsonObject& obj) void Index::merge(const std::shared_ptr &other) { - const QVector lists = std::dynamic_pointer_cast(other)->m_lists; + const QVector lists = std::dynamic_pointer_cast(other)->m_lists; // initial load, no need to merge if (m_lists.isEmpty()) { @@ -120,7 +120,7 @@ void Index::merge(const std::shared_ptr &other) } else { - for (const VersionListPtr &list : lists) + for (const VersionList::Ptr &list : lists) { if (m_uids.contains(list->uid())) { @@ -138,7 +138,7 @@ void Index::merge(const std::shared_ptr &other) } } -void Index::connectVersionList(const int row, const VersionListPtr &list) +void Index::connectVersionList(const int row, const VersionList::Ptr &list) { connect(list.get(), &VersionList::nameChanged, this, [this, row]() { diff --git a/launcher/meta/Index.h b/launcher/meta/Index.h index d33ab0c8..06ea09dc 100644 --- a/launcher/meta/Index.h +++ b/launcher/meta/Index.h @@ -19,20 +19,19 @@ #include #include "BaseEntity.h" +#include "meta/VersionList.h" class Task; namespace Meta { -using VersionListPtr = std::shared_ptr; -using VersionPtr = std::shared_ptr; class Index : public QAbstractListModel, public BaseEntity { Q_OBJECT public: explicit Index(QObject *parent = nullptr); - explicit Index(const QVector &lists, QObject *parent = nullptr); + explicit Index(const QVector &lists, QObject *parent = nullptr); enum { @@ -49,21 +48,21 @@ public: QString localFilename() const override { return "index.json"; } // queries - VersionListPtr get(const QString &uid); - VersionPtr get(const QString &uid, const QString &version); + VersionList::Ptr get(const QString &uid); + Version::Ptr get(const QString &uid, const QString &version); bool hasUid(const QString &uid) const; - QVector lists() const { return m_lists; } + QVector lists() const { return m_lists; } public: // for usage by parsers only void merge(const std::shared_ptr &other); void parse(const QJsonObject &obj) override; private: - QVector m_lists; - QHash m_uids; + QVector m_lists; + QHash m_uids; - void connectVersionList(const int row, const VersionListPtr &list); + void connectVersionList(const int row, const VersionList::Ptr &list); }; } diff --git a/launcher/meta/JsonFormat.cpp b/launcher/meta/JsonFormat.cpp index 796da4bb..473f37d6 100644 --- a/launcher/meta/JsonFormat.cpp +++ b/launcher/meta/JsonFormat.cpp @@ -37,11 +37,11 @@ MetadataVersion currentFormatVersion() static std::shared_ptr parseIndexInternal(const QJsonObject &obj) { const QVector objects = requireIsArrayOf(obj, "packages"); - QVector lists; + QVector lists; lists.reserve(objects.size()); std::transform(objects.begin(), objects.end(), std::back_inserter(lists), [](const QJsonObject &obj) { - VersionListPtr list = std::make_shared(requireString(obj, "uid")); + VersionList::Ptr list = std::make_shared(requireString(obj, "uid")); list->setName(ensureString(obj, "name", QString())); return list; }); @@ -49,9 +49,9 @@ static std::shared_ptr parseIndexInternal(const QJsonObject &obj) } // Version -static VersionPtr parseCommonVersion(const QString &uid, const QJsonObject &obj) +static Version::Ptr parseCommonVersion(const QString &uid, const QJsonObject &obj) { - VersionPtr version = std::make_shared(uid, requireString(obj, "version")); + Version::Ptr version = std::make_shared(uid, requireString(obj, "version")); version->setTime(QDateTime::fromString(requireString(obj, "releaseTime"), Qt::ISODate).toMSecsSinceEpoch() / 1000); version->setType(ensureString(obj, "type", QString())); version->setRecommended(ensureBoolean(obj, QString("recommended"), false)); @@ -63,9 +63,9 @@ static VersionPtr parseCommonVersion(const QString &uid, const QJsonObject &obj) return version; } -static std::shared_ptr parseVersionInternal(const QJsonObject &obj) +static Version::Ptr parseVersionInternal(const QJsonObject &obj) { - VersionPtr version = parseCommonVersion(requireString(obj, "uid"), obj); + Version::Ptr version = parseCommonVersion(requireString(obj, "uid"), obj); version->setData(OneSixVersionFormat::versionFileFromJson(QJsonDocument(obj), QString("%1/%2.json").arg(version->uid(), version->version()), @@ -74,12 +74,12 @@ static std::shared_ptr parseVersionInternal(const QJsonObject &obj) } // Version list / package -static std::shared_ptr parseVersionListInternal(const QJsonObject &obj) +static VersionList::Ptr parseVersionListInternal(const QJsonObject &obj) { const QString uid = requireString(obj, "uid"); const QVector versionsRaw = requireIsArrayOf(obj, "versions"); - QVector versions; + QVector versions; versions.reserve(versionsRaw.size()); std::transform(versionsRaw.begin(), versionsRaw.end(), std::back_inserter(versions), [uid](const QJsonObject &vObj) { @@ -88,7 +88,7 @@ static std::shared_ptr parseVersionListInternal(const QJsonObject & return version; }); - VersionListPtr list = std::make_shared(uid); + VersionList::Ptr list = std::make_shared(uid); list->setName(ensureString(obj, "name", QString())); list->setVersions(versions); return list; diff --git a/launcher/meta/Version.cpp b/launcher/meta/Version.cpp index a8dc3169..68cfa55c 100644 --- a/launcher/meta/Version.cpp +++ b/launcher/meta/Version.cpp @@ -54,7 +54,7 @@ void Meta::Version::parse(const QJsonObject& obj) parseVersion(obj, this); } -void Meta::Version::mergeFromList(const Meta::VersionPtr& other) +void Meta::Version::mergeFromList(const Meta::Version::Ptr& other) { if(other->m_providesRecommendations) { @@ -85,7 +85,7 @@ void Meta::Version::mergeFromList(const Meta::VersionPtr& other) } } -void Meta::Version::merge(const VersionPtr &other) +void Meta::Version::merge(const Version::Ptr &other) { mergeFromList(other); if(other->m_data) diff --git a/launcher/meta/Version.h b/launcher/meta/Version.h index dea8dc8a..7228fa36 100644 --- a/launcher/meta/Version.h +++ b/launcher/meta/Version.h @@ -30,13 +30,14 @@ namespace Meta { -using VersionPtr = std::shared_ptr; class Version : public QObject, public BaseVersion, public BaseEntity { Q_OBJECT -public: /* con/des */ +public: + using Ptr = std::shared_ptr; + explicit Version(const QString &uid, const QString &version); virtual ~Version(); @@ -78,8 +79,8 @@ public: /* con/des */ return m_data != nullptr; } - void merge(const VersionPtr &other); - void mergeFromList(const VersionPtr &other); + void merge(const Version::Ptr &other); + void mergeFromList(const Version::Ptr &other); void parse(const QJsonObject &obj) override; QString localFilename() const override; @@ -113,4 +114,4 @@ private: }; } -Q_DECLARE_METATYPE(Meta::VersionPtr) +Q_DECLARE_METATYPE(Meta::Version::Ptr) diff --git a/launcher/meta/VersionList.cpp b/launcher/meta/VersionList.cpp index f609e94c..7f001dfc 100644 --- a/launcher/meta/VersionList.cpp +++ b/launcher/meta/VersionList.cpp @@ -40,7 +40,7 @@ bool VersionList::isLoaded() return BaseEntity::isLoaded(); } -const BaseVersionPtr VersionList::at(int i) const +const BaseVersion::Ptr VersionList::at(int i) const { return m_versions.at(i); } @@ -52,7 +52,7 @@ int VersionList::count() const void VersionList::sortVersions() { beginResetModel(); - std::sort(m_versions.begin(), m_versions.end(), [](const VersionPtr &a, const VersionPtr &b) + std::sort(m_versions.begin(), m_versions.end(), [](const Version::Ptr &a, const Version::Ptr &b) { return *a.get() < *b.get(); }); @@ -66,7 +66,7 @@ QVariant VersionList::data(const QModelIndex &index, int role) const return QVariant(); } - VersionPtr version = m_versions.at(index.row()); + Version::Ptr version = m_versions.at(index.row()); switch (role) { @@ -129,9 +129,9 @@ QString VersionList::humanReadable() const return m_name.isEmpty() ? m_uid : m_name; } -VersionPtr VersionList::getVersion(const QString &version) +Version::Ptr VersionList::getVersion(const QString &version) { - VersionPtr out = m_lookup.value(version, nullptr); + Version::Ptr out = m_lookup.value(version, nullptr); if(!out) { out = std::make_shared(m_uid, version); @@ -143,7 +143,7 @@ VersionPtr VersionList::getVersion(const QString &version) bool VersionList::hasVersion(QString version) const { auto ver = std::find_if(m_versions.constBegin(), m_versions.constEnd(), - [&](Meta::VersionPtr const& a){ return a->version() == version; }); + [&](Meta::Version::Ptr const& a){ return a->version() == version; }); return (ver != m_versions.constEnd()); } @@ -153,11 +153,11 @@ void VersionList::setName(const QString &name) emit nameChanged(name); } -void VersionList::setVersions(const QVector &versions) +void VersionList::setVersions(const QVector &versions) { beginResetModel(); m_versions = versions; - std::sort(m_versions.begin(), m_versions.end(), [](const VersionPtr &a, const VersionPtr &b) + std::sort(m_versions.begin(), m_versions.end(), [](const Version::Ptr &a, const Version::Ptr &b) { return a->rawTime() > b->rawTime(); }); @@ -168,7 +168,7 @@ void VersionList::setVersions(const QVector &versions) } // FIXME: this is dumb, we have 'recommended' as part of the metadata already... - auto recommendedIt = std::find_if(m_versions.constBegin(), m_versions.constEnd(), [](const VersionPtr &ptr) { return ptr->type() == "release"; }); + auto recommendedIt = std::find_if(m_versions.constBegin(), m_versions.constEnd(), [](const Version::Ptr &ptr) { return ptr->type() == "release"; }); m_recommended = recommendedIt == m_versions.constEnd() ? nullptr : *recommendedIt; endResetModel(); } @@ -179,7 +179,7 @@ void VersionList::parse(const QJsonObject& obj) } // FIXME: this is dumb, we have 'recommended' as part of the metadata already... -static const Meta::VersionPtr &getBetterVersion(const Meta::VersionPtr &a, const Meta::VersionPtr &b) +static const Meta::Version::Ptr &getBetterVersion(const Meta::Version::Ptr &a, const Meta::Version::Ptr &b) { if(!a) return b; @@ -194,7 +194,7 @@ static const Meta::VersionPtr &getBetterVersion(const Meta::VersionPtr &a, const return (a->type() == "release" ? a : b); } -void VersionList::mergeFromIndex(const VersionListPtr &other) +void VersionList::mergeFromIndex(const VersionList::Ptr &other) { if (m_name != other->m_name) { @@ -202,7 +202,7 @@ void VersionList::mergeFromIndex(const VersionListPtr &other) } } -void VersionList::merge(const VersionListPtr &other) +void VersionList::merge(const VersionList::Ptr &other) { if (m_name != other->m_name) { @@ -216,7 +216,7 @@ void VersionList::merge(const VersionListPtr &other) { qWarning() << "Empty list loaded ..."; } - for (const VersionPtr &version : other->m_versions) + for (const Version::Ptr &version : other->m_versions) { // we already have the version. merge the contents if (m_lookup.contains(version->version())) @@ -235,7 +235,7 @@ void VersionList::merge(const VersionListPtr &other) endResetModel(); } -void VersionList::setupAddedVersion(const int row, const VersionPtr &version) +void VersionList::setupAddedVersion(const int row, const Version::Ptr &version) { // FIXME: do not disconnect from everythin, disconnect only the lambdas here version->disconnect(); @@ -244,7 +244,7 @@ void VersionList::setupAddedVersion(const int row, const VersionPtr &version) connect(version.get(), &Version::typeChanged, this, [this, row]() { emit dataChanged(index(row), index(row), QVector() << TypeRole); }); } -BaseVersionPtr VersionList::getRecommended() const +BaseVersion::Ptr VersionList::getRecommended() const { return m_recommended; } diff --git a/launcher/meta/VersionList.h b/launcher/meta/VersionList.h index a6db2fd7..a4d5603d 100644 --- a/launcher/meta/VersionList.h +++ b/launcher/meta/VersionList.h @@ -20,10 +20,10 @@ #include #include +#include "meta/Version.h" + namespace Meta { -using VersionPtr = std::shared_ptr; -using VersionListPtr = std::shared_ptr; class VersionList : public BaseVersionList, public BaseEntity { @@ -33,6 +33,8 @@ class VersionList : public BaseVersionList, public BaseEntity public: explicit VersionList(const QString &uid, QObject *parent = nullptr); + using Ptr = std::shared_ptr; + enum Roles { UidRole = Qt::UserRole + 100, @@ -43,11 +45,11 @@ public: Task::Ptr getLoadTask() override; bool isLoaded() override; - const BaseVersionPtr at(int i) const override; + const BaseVersion::Ptr at(int i) const override; int count() const override; void sortVersions() override; - BaseVersionPtr getRecommended() const override; + BaseVersion::Ptr getRecommended() const override; QVariant data(const QModelIndex &index, int role) const override; RoleList providesRoles() const override; @@ -65,38 +67,38 @@ public: } QString humanReadable() const; - VersionPtr getVersion(const QString &version); + Version::Ptr getVersion(const QString &version); bool hasVersion(QString version) const; - QVector versions() const + QVector versions() const { return m_versions; } public: // for usage only by parsers void setName(const QString &name); - void setVersions(const QVector &versions); - void merge(const VersionListPtr &other); - void mergeFromIndex(const VersionListPtr &other); + void setVersions(const QVector &versions); + void merge(const VersionList::Ptr &other); + void mergeFromIndex(const VersionList::Ptr &other); void parse(const QJsonObject &obj) override; signals: void nameChanged(const QString &name); protected slots: - void updateListData(QList) override + void updateListData(QList) override { } private: - QVector m_versions; - QHash m_lookup; + QVector m_versions; + QHash m_lookup; QString m_uid; QString m_name; - VersionPtr m_recommended; + Version::Ptr m_recommended; - void setupAddedVersion(const int row, const VersionPtr &version); + void setupAddedVersion(const int row, const Version::Ptr &version); }; } -Q_DECLARE_METATYPE(Meta::VersionListPtr) +Q_DECLARE_METATYPE(Meta::VersionList::Ptr) diff --git a/launcher/minecraft/VanillaInstanceCreationTask.cpp b/launcher/minecraft/VanillaInstanceCreationTask.cpp index c45daa9a..0bb92e87 100644 --- a/launcher/minecraft/VanillaInstanceCreationTask.cpp +++ b/launcher/minecraft/VanillaInstanceCreationTask.cpp @@ -7,7 +7,7 @@ #include "minecraft/PackProfile.h" #include "settings/INISettingsObject.h" -VanillaCreationTask::VanillaCreationTask(BaseVersionPtr version, QString loader, BaseVersionPtr loader_version) +VanillaCreationTask::VanillaCreationTask(BaseVersion::Ptr version, QString loader, BaseVersion::Ptr loader_version) : InstanceCreationTask(), m_version(std::move(version)), m_using_loader(true), m_loader(std::move(loader)), m_loader_version(std::move(loader_version)) {} diff --git a/launcher/minecraft/VanillaInstanceCreationTask.h b/launcher/minecraft/VanillaInstanceCreationTask.h index 7a37bbd6..d1b81682 100644 --- a/launcher/minecraft/VanillaInstanceCreationTask.h +++ b/launcher/minecraft/VanillaInstanceCreationTask.h @@ -7,16 +7,16 @@ class VanillaCreationTask final : public InstanceCreationTask { Q_OBJECT public: - VanillaCreationTask(BaseVersionPtr version) : InstanceCreationTask(), m_version(std::move(version)) {} - VanillaCreationTask(BaseVersionPtr version, QString loader, BaseVersionPtr loader_version); + VanillaCreationTask(BaseVersion::Ptr version) : InstanceCreationTask(), m_version(std::move(version)) {} + VanillaCreationTask(BaseVersion::Ptr version, QString loader, BaseVersion::Ptr loader_version); bool createInstance() override; private: // Version to update to / create of the instance. - BaseVersionPtr m_version; + BaseVersion::Ptr m_version; bool m_using_loader = false; QString m_loader; - BaseVersionPtr m_loader_version; + BaseVersion::Ptr m_loader_version; }; diff --git a/launcher/modplatform/atlauncher/ATLPackInstallTask.cpp b/launcher/modplatform/atlauncher/ATLPackInstallTask.cpp index 68d75943..291ad916 100644 --- a/launcher/modplatform/atlauncher/ATLPackInstallTask.cpp +++ b/launcher/modplatform/atlauncher/ATLPackInstallTask.cpp @@ -58,7 +58,7 @@ namespace ATLauncher { -static Meta::VersionPtr getComponentVersion(const QString& uid, const QString& version); +static Meta::Version::Ptr getComponentVersion(const QString& uid, const QString& version); PackInstallTask::PackInstallTask(UserInteractionSupport *support, QString packName, QString version, InstallMode installMode) { @@ -1037,7 +1037,7 @@ void PackInstallTask::install() emitSucceeded(); } -static Meta::VersionPtr getComponentVersion(const QString& uid, const QString& version) +static Meta::Version::Ptr getComponentVersion(const QString& uid, const QString& version) { auto vlist = APPLICATION->metadataIndex()->get(uid); if (!vlist) diff --git a/launcher/modplatform/atlauncher/ATLPackInstallTask.h b/launcher/modplatform/atlauncher/ATLPackInstallTask.h index 78cd87fb..90e25ae2 100644 --- a/launcher/modplatform/atlauncher/ATLPackInstallTask.h +++ b/launcher/modplatform/atlauncher/ATLPackInstallTask.h @@ -68,7 +68,7 @@ public: * Requests a user interaction to select a component version from a given version list * and constrained to a given Minecraft version. */ - virtual QString chooseVersion(Meta::VersionListPtr vlist, QString minecraftVersion) = 0; + virtual QString chooseVersion(Meta::VersionList::Ptr vlist, QString minecraftVersion) = 0; /** * Requests a user interaction to display a message. @@ -137,8 +137,8 @@ private: QString archivePath; QStringList jarmods; - Meta::VersionPtr minecraftVersion; - QMap componentsToInstall; + Meta::Version::Ptr minecraftVersion; + QMap componentsToInstall; QFuture> m_extractFuture; QFutureWatcher> m_extractFutureWatcher; diff --git a/launcher/ui/dialogs/VersionSelectDialog.cpp b/launcher/ui/dialogs/VersionSelectDialog.cpp index 70ef72d6..d7880334 100644 --- a/launcher/ui/dialogs/VersionSelectDialog.cpp +++ b/launcher/ui/dialogs/VersionSelectDialog.cpp @@ -120,7 +120,7 @@ void VersionSelectDialog::selectRecommended() m_versionWidget->selectRecommended(); } -BaseVersionPtr VersionSelectDialog::selectedVersion() const +BaseVersion::Ptr VersionSelectDialog::selectedVersion() const { return m_versionWidget->selectedVersion(); } diff --git a/launcher/ui/dialogs/VersionSelectDialog.h b/launcher/ui/dialogs/VersionSelectDialog.h index ed30d3f3..18a50cdb 100644 --- a/launcher/ui/dialogs/VersionSelectDialog.h +++ b/launcher/ui/dialogs/VersionSelectDialog.h @@ -44,7 +44,7 @@ public: int exec() override; - BaseVersionPtr selectedVersion() const; + BaseVersion::Ptr selectedVersion() const; void setCurrentVersion(const QString & version); void setFuzzyFilter(BaseVersionList::ModelRoles role, QString filter); diff --git a/launcher/ui/pages/modplatform/VanillaPage.cpp b/launcher/ui/pages/modplatform/VanillaPage.cpp index 99190f31..29fecb85 100644 --- a/launcher/ui/pages/modplatform/VanillaPage.cpp +++ b/launcher/ui/pages/modplatform/VanillaPage.cpp @@ -187,12 +187,12 @@ void VanillaPage::retranslate() ui->retranslateUi(this); } -BaseVersionPtr VanillaPage::selectedVersion() const +BaseVersion::Ptr VanillaPage::selectedVersion() const { return m_selectedVersion; } -BaseVersionPtr VanillaPage::selectedLoaderVersion() const +BaseVersion::Ptr VanillaPage::selectedLoaderVersion() const { return m_selectedLoaderVersion; } @@ -227,14 +227,14 @@ void VanillaPage::suggestCurrent() dialog->setSuggestedIcon("default"); } -void VanillaPage::setSelectedVersion(BaseVersionPtr version) +void VanillaPage::setSelectedVersion(BaseVersion::Ptr version) { m_selectedVersion = version; suggestCurrent(); loaderFilterChanged(); } -void VanillaPage::setSelectedLoaderVersion(BaseVersionPtr version) +void VanillaPage::setSelectedLoaderVersion(BaseVersion::Ptr version) { m_selectedLoaderVersion = version; suggestCurrent(); diff --git a/launcher/ui/pages/modplatform/VanillaPage.h b/launcher/ui/pages/modplatform/VanillaPage.h index 7193597d..39aba760 100644 --- a/launcher/ui/pages/modplatform/VanillaPage.h +++ b/launcher/ui/pages/modplatform/VanillaPage.h @@ -76,13 +76,13 @@ public: void openedImpl() override; - BaseVersionPtr selectedVersion() const; - BaseVersionPtr selectedLoaderVersion() const; + BaseVersion::Ptr selectedVersion() const; + BaseVersion::Ptr selectedLoaderVersion() const; QString selectedLoader() const; public slots: - void setSelectedVersion(BaseVersionPtr version); - void setSelectedLoaderVersion(BaseVersionPtr version); + void setSelectedVersion(BaseVersion::Ptr version); + void setSelectedLoaderVersion(BaseVersion::Ptr version); private slots: void filterChanged(); @@ -98,7 +98,7 @@ private: NewInstanceDialog *dialog = nullptr; Ui::VanillaPage *ui = nullptr; bool m_versionSetByUser = false; - BaseVersionPtr m_selectedVersion; - BaseVersionPtr m_selectedLoaderVersion; + BaseVersion::Ptr m_selectedVersion; + BaseVersion::Ptr m_selectedLoaderVersion; QString m_selectedLoader; }; diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.cpp b/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.cpp index c68e40ba..f5f50cae 100644 --- a/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.cpp +++ b/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.cpp @@ -53,7 +53,7 @@ std::optional> AtlUserInteractionSupportImpl::chooseOptionalMod return optionalModDialog.getResult(); } -QString AtlUserInteractionSupportImpl::chooseVersion(Meta::VersionListPtr vlist, QString minecraftVersion) +QString AtlUserInteractionSupportImpl::chooseVersion(Meta::VersionList::Ptr vlist, QString minecraftVersion) { VersionSelectDialog vselect(vlist.get(), "Choose Version", m_parent, false); if (minecraftVersion != nullptr) { diff --git a/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.h b/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.h index 3b37c9be..37010b3f 100644 --- a/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.h +++ b/launcher/ui/pages/modplatform/atlauncher/AtlUserInteractionSupportImpl.h @@ -46,7 +46,7 @@ public: AtlUserInteractionSupportImpl(QWidget* parent); private: - QString chooseVersion(Meta::VersionListPtr vlist, QString minecraftVersion) override; + QString chooseVersion(Meta::VersionList::Ptr vlist, QString minecraftVersion) override; std::optional> chooseOptionalMods(ATLauncher::PackVersion version, QVector mods) override; void displayMessage(QString message) override; diff --git a/launcher/ui/widgets/JavaSettingsWidget.cpp b/launcher/ui/widgets/JavaSettingsWidget.cpp index 314a126e..c7c4dbbd 100644 --- a/launcher/ui/widgets/JavaSettingsWidget.cpp +++ b/launcher/ui/widgets/JavaSettingsWidget.cpp @@ -245,7 +245,7 @@ void JavaSettingsWidget::memoryValueChanged(int) } } -void JavaSettingsWidget::javaVersionSelected(BaseVersionPtr version) +void JavaSettingsWidget::javaVersionSelected(BaseVersion::Ptr version) { auto java = std::dynamic_pointer_cast(version); if(!java) diff --git a/launcher/ui/widgets/JavaSettingsWidget.h b/launcher/ui/widgets/JavaSettingsWidget.h index 0d280daf..5344e2cd 100644 --- a/launcher/ui/widgets/JavaSettingsWidget.h +++ b/launcher/ui/widgets/JavaSettingsWidget.h @@ -60,7 +60,7 @@ public: protected slots: void memoryValueChanged(int); void javaPathEdited(const QString &path); - void javaVersionSelected(BaseVersionPtr version); + void javaVersionSelected(BaseVersion::Ptr version); void on_javaBrowseBtn_clicked(); void on_javaStatusBtn_clicked(); void checkFinished(JavaCheckResult result); diff --git a/launcher/ui/widgets/ModFilterWidget.h b/launcher/ui/widgets/ModFilterWidget.h index 958a1e2b..706ffd21 100644 --- a/launcher/ui/widgets/ModFilterWidget.h +++ b/launcher/ui/widgets/ModFilterWidget.h @@ -49,7 +49,7 @@ public: auto getFilter() -> std::shared_ptr; auto changed() const -> bool { return m_last_version_id != m_version_id; } - Meta::VersionListPtr versionList() { return m_version_list; } + Meta::VersionList::Ptr versionList() { return m_version_list; } private: ModFilterWidget(Version def, QWidget* parent = nullptr); @@ -73,7 +73,7 @@ private: /* Version stuff */ QButtonGroup m_mcVersion_buttons; - Meta::VersionListPtr m_version_list; + Meta::VersionList::Ptr m_version_list; /* Used to tell if the filter was changed since the last getFilter() call */ VersionButtonID m_last_version_id = VersionButtonID::Strict; diff --git a/launcher/ui/widgets/VersionSelectWidget.cpp b/launcher/ui/widgets/VersionSelectWidget.cpp index cc4fc6a2..404860d9 100644 --- a/launcher/ui/widgets/VersionSelectWidget.cpp +++ b/launcher/ui/widgets/VersionSelectWidget.cpp @@ -142,7 +142,7 @@ void VersionSelectWidget::changeProgress(qint64 current, qint64 total) void VersionSelectWidget::currentRowChanged(const QModelIndex& current, const QModelIndex&) { auto variant = m_proxyModel->data(current, BaseVersionList::VersionPointerRole); - emit selectedVersionChanged(variant.value()); + emit selectedVersionChanged(variant.value()); } void VersionSelectWidget::preselect() @@ -186,11 +186,11 @@ bool VersionSelectWidget::hasVersions() const return m_proxyModel->rowCount(QModelIndex()) != 0; } -BaseVersionPtr VersionSelectWidget::selectedVersion() const +BaseVersion::Ptr VersionSelectWidget::selectedVersion() const { auto currentIndex = listView->selectionModel()->currentIndex(); auto variant = m_proxyModel->data(currentIndex, BaseVersionList::VersionPointerRole); - return variant.value(); + return variant.value(); } void VersionSelectWidget::setExactFilter(BaseVersionList::ModelRoles role, QString filter) diff --git a/launcher/ui/widgets/VersionSelectWidget.h b/launcher/ui/widgets/VersionSelectWidget.h index f56daa8a..e75efc6f 100644 --- a/launcher/ui/widgets/VersionSelectWidget.h +++ b/launcher/ui/widgets/VersionSelectWidget.h @@ -40,7 +40,7 @@ public: void loadList(); bool hasVersions() const; - BaseVersionPtr selectedVersion() const; + BaseVersion::Ptr selectedVersion() const; void selectRecommended(); void selectCurrent(); @@ -54,7 +54,7 @@ public: void setResizeOn(int column); signals: - void selectedVersionChanged(BaseVersionPtr version); + void selectedVersionChanged(BaseVersion::Ptr version); protected: virtual void closeEvent ( QCloseEvent* );