From 14854a6187d665bde519bbb5baf4cc60505f3af0 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sun, 17 Sep 2023 09:02:11 -0400 Subject: [PATCH] Small C++ fixes --- launcher/include/assetupdater.h | 6 +++--- launcher/include/launchercore.h | 2 +- launcher/src/accountmanager.cpp | 6 +++--- launcher/src/assetupdater.cpp | 6 ++---- launcher/src/profile.cpp | 1 - launcher/src/profilemanager.cpp | 8 ++++---- 6 files changed, 13 insertions(+), 16 deletions(-) diff --git a/launcher/include/assetupdater.h b/launcher/include/assetupdater.h index 2f0d145..3e284ef 100644 --- a/launcher/include/assetupdater.h +++ b/launcher/include/assetupdater.h @@ -30,9 +30,9 @@ Q_SIGNALS: void finishedUpdating(); private: - QUrl dalamudVersionManifestUrl(Profile::DalamudChannel channel) const; - QUrl dalamudLatestPackageUrl(Profile::DalamudChannel channel) const; - QUrl dalamudAssetManifestUrl() const; + [[nodiscard]] QUrl dalamudVersionManifestUrl(Profile::DalamudChannel channel) const; + [[nodiscard]] QUrl dalamudLatestPackageUrl(Profile::DalamudChannel channel) const; + [[nodiscard]] QUrl dalamudAssetManifestUrl() const; LauncherCore &launcher; diff --git a/launcher/include/launchercore.h b/launcher/include/launchercore.h index 6c976c1..647ed85 100755 --- a/launcher/include/launchercore.h +++ b/launcher/include/launchercore.h @@ -148,7 +148,7 @@ public: [[nodiscard]] bool isSteamDeck() const; Q_INVOKABLE void refreshNews(); - Headline *headline() const; + [[nodiscard]] Headline *headline() const; Q_INVOKABLE void openOfficialLauncher(Profile *profile); Q_INVOKABLE void openSystemInfo(Profile *profile); diff --git a/launcher/src/accountmanager.cpp b/launcher/src/accountmanager.cpp index 6407b95..37f28ef 100644 --- a/launcher/src/accountmanager.cpp +++ b/launcher/src/accountmanager.cpp @@ -25,7 +25,7 @@ void AccountManager::load() int AccountManager::rowCount(const QModelIndex &index) const { Q_UNUSED(index); - return m_accounts.size(); + return static_cast(m_accounts.size()); } QVariant AccountManager::data(const QModelIndex &index, int role) const @@ -95,7 +95,7 @@ void AccountManager::deleteAccount(Account *account) config->deleteGroup(QStringLiteral("account-%1").arg(account->uuid())); config->sync(); - const int row = m_accounts.indexOf(account); + const int row = static_cast(m_accounts.indexOf(account)); beginRemoveRows(QModelIndex(), row, row); m_accounts.removeAll(account); endRemoveRows(); @@ -103,7 +103,7 @@ void AccountManager::deleteAccount(Account *account) void AccountManager::insertAccount(Account *account) { - beginInsertRows(QModelIndex(), m_accounts.size(), m_accounts.size()); + beginInsertRows(QModelIndex(), static_cast(m_accounts.size()), static_cast(m_accounts.size())); m_accounts.append(account); endInsertRows(); } diff --git a/launcher/src/assetupdater.cpp b/launcher/src/assetupdater.cpp index b0ed487..566d76c 100644 --- a/launcher/src/assetupdater.cpp +++ b/launcher/src/assetupdater.cpp @@ -4,7 +4,6 @@ #include "assetupdater.h" #include -#include #include #include #include @@ -17,6 +16,7 @@ const QString dotnetDesktopPackageURL = "https://dotnetcli.azureedge.net/dotnet/ AssetUpdater::AssetUpdater(Profile &profile, LauncherCore &launcher, QObject *parent) : QObject(parent) , launcher(launcher) + , chosenChannel(profile.dalamudChannel()) , m_profile(profile) { launcher.mgr->setRedirectPolicy(QNetworkRequest::NoLessSafeRedirectPolicy); @@ -86,8 +86,6 @@ void AssetUpdater::update() { QNetworkRequest request(dalamudVersionManifestUrl(m_profile.dalamudChannel())); - chosenChannel = m_profile.dalamudChannel(); - remoteDalamudVersion.clear(); remoteRuntimeVersion.clear(); @@ -106,7 +104,7 @@ void AssetUpdater::update() // bytes, ex: \xFF\xFE{\x00\"\x00""A\x00s\x00s\x00""e\x00m\x00 so we // start at the first character of the json '{' and work our way up. QString reassmbled; - for (int i = str.indexOf('{'); i < str.size(); i++) { + for (int i = static_cast(str.indexOf('{')); i < str.size(); i++) { char t = str[i]; if (QChar(t).isPrint()) reassmbled += t; diff --git a/launcher/src/profile.cpp b/launcher/src/profile.cpp index 40e9d13..fa863c5 100644 --- a/launcher/src/profile.cpp +++ b/launcher/src/profile.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include "account.h" diff --git a/launcher/src/profilemanager.cpp b/launcher/src/profilemanager.cpp index 4dfd2f6..0b338b6 100644 --- a/launcher/src/profilemanager.cpp +++ b/launcher/src/profilemanager.cpp @@ -48,7 +48,7 @@ void ProfileManager::deleteProfile(Profile *profile) config->deleteGroup(QStringLiteral("profile-%1").arg(profile->uuid())); config->sync(); - const int row = m_profiles.indexOf(profile); + const int row = static_cast(m_profiles.indexOf(profile)); beginRemoveRows(QModelIndex(), row, row); m_profiles.removeAll(profile); endRemoveRows(); @@ -64,7 +64,7 @@ QString ProfileManager::getDefaultWinePrefixPath() return QDir::homePath() + QStringLiteral("/.wine"); #endif - return ""; + Q_UNREACHABLE(); } QString ProfileManager::getDefaultGamePath(const QString &uuid) @@ -105,7 +105,7 @@ void ProfileManager::load() int ProfileManager::rowCount(const QModelIndex &index) const { Q_UNUSED(index); - return m_profiles.size(); + return static_cast(m_profiles.size()); } QVariant ProfileManager::data(const QModelIndex &index, int role) const @@ -129,7 +129,7 @@ QHash ProfileManager::roleNames() const void ProfileManager::insertProfile(Profile *profile) { - beginInsertRows(QModelIndex(), m_profiles.size(), m_profiles.size()); + beginInsertRows(QModelIndex(), static_cast(m_profiles.size()), static_cast(m_profiles.size())); m_profiles.append(profile); endInsertRows(); }