summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2021-05-17 21:00:13 +0200
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2021-11-02 13:50:21 +0100
commitab252aedfa95095fe0e9a458e161b164c1156ca7 (patch)
treeaf01ce621baeb1f3aa72287a88575233524cd208 /Source/Core
parentdb02b50d2ecdfbbc21e19aadc57253c353069f77 (diff)
Core, DolphinQt, UICommon: Fix all cases of -Wrange-loop-construct in gcc 11
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp7
-rw-r--r--Source/Core/DolphinQt/Resources.cpp23
-rw-r--r--Source/Core/DolphinQt/Resources.h11
-rw-r--r--Source/Core/DolphinQt/Settings/GameCubePane.cpp2
-rw-r--r--Source/Core/UICommon/GameFileCache.cpp2
5 files changed, 25 insertions, 20 deletions
diff --git a/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp b/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp
index 4bce44b62e..10aa72c3b5 100644
--- a/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp
+++ b/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp
@@ -546,8 +546,11 @@ void BluetoothRealDevice::SaveLinkKeys()
oss << Common::MacAddressToString(address);
oss << '=';
oss << std::hex;
- for (const u16& data : entry.second)
- oss << std::setfill('0') << std::setw(2) << data;
+ for (u8 data : entry.second)
+ {
+ // We cast to u16 here in order to have it displayed as two nibbles.
+ oss << std::setfill('0') << std::setw(2) << static_cast<u16>(data);
+ }
oss << std::dec << ',';
}
std::string config_string = oss.str();
diff --git a/Source/Core/DolphinQt/Resources.cpp b/Source/Core/DolphinQt/Resources.cpp
index e10f8acfd4..2ab51fb536 100644
--- a/Source/Core/DolphinQt/Resources.cpp
+++ b/Source/Core/DolphinQt/Resources.cpp
@@ -21,9 +21,10 @@ QList<QPixmap> Resources::m_platforms;
QList<QPixmap> Resources::m_countries;
QList<QPixmap> Resources::m_misc;
-QIcon Resources::GetIcon(const QString& name, const QString& dir)
+QIcon Resources::GetIcon(std::string_view name, const QString& dir)
{
- QString base_path = dir + QLatin1Char{'/'} + name;
+ QString name_owned = QString::fromLatin1(name.data(), static_cast<int>(name.size()));
+ QString base_path = dir + QLatin1Char{'/'} + name_owned;
const auto dpr = QGuiApplication::primaryScreen()->devicePixelRatio();
@@ -42,7 +43,7 @@ QIcon Resources::GetIcon(const QString& name, const QString& dir)
return icon;
}
-QPixmap Resources::GetPixmap(const QString& name, const QString& dir)
+QPixmap Resources::GetPixmap(std::string_view name, const QString& dir)
{
const auto icon = GetIcon(name, dir);
return icon.pixmap(icon.availableSizes()[0]);
@@ -58,30 +59,30 @@ static QString GetResourcesDir()
return QString::fromStdString(File::GetSysDirectory() + "Resources");
}
-QIcon Resources::GetScaledIcon(const std::string& name)
+QIcon Resources::GetScaledIcon(std::string_view name)
{
- return GetIcon(QString::fromStdString(name), GetResourcesDir());
+ return GetIcon(name, GetResourcesDir());
}
-QIcon Resources::GetScaledThemeIcon(const std::string& name)
+QIcon Resources::GetScaledThemeIcon(std::string_view name)
{
- return GetIcon(QString::fromStdString(name), GetCurrentThemeDir());
+ return GetIcon(name, GetCurrentThemeDir());
}
-QPixmap Resources::GetScaledPixmap(const std::string& name)
+QPixmap Resources::GetScaledPixmap(std::string_view name)
{
- return GetPixmap(QString::fromStdString(name), GetResourcesDir());
+ return GetPixmap(name, GetResourcesDir());
}
void Resources::Init()
{
- for (const std::string& platform :
+ for (std::string_view platform :
{"Platform_Gamecube", "Platform_Wii", "Platform_Wad", "Platform_File"})
{
m_platforms.append(GetScaledPixmap(platform));
}
- for (const std::string& country :
+ for (std::string_view country :
{"Flag_Europe", "Flag_Japan", "Flag_USA", "Flag_Australia", "Flag_France", "Flag_Germany",
"Flag_Italy", "Flag_Korea", "Flag_Netherlands", "Flag_Russia", "Flag_Spain", "Flag_Taiwan",
"Flag_International", "Flag_Unknown"})
diff --git a/Source/Core/DolphinQt/Resources.h b/Source/Core/DolphinQt/Resources.h
index 923c1bf1d9..67ffc23d4d 100644
--- a/Source/Core/DolphinQt/Resources.h
+++ b/Source/Core/DolphinQt/Resources.h
@@ -5,6 +5,7 @@
#include <QList>
#include <QPixmap>
+#include <string_view>
namespace DiscIO
{
@@ -30,16 +31,16 @@ public:
static QPixmap GetMisc(MiscID id);
- static QIcon GetScaledIcon(const std::string& name);
- static QIcon GetScaledThemeIcon(const std::string& name);
+ static QIcon GetScaledIcon(std::string_view name);
+ static QIcon GetScaledThemeIcon(std::string_view name);
static QIcon GetAppIcon();
- static QPixmap GetScaledPixmap(const std::string& name);
+ static QPixmap GetScaledPixmap(std::string_view name);
private:
Resources() {}
- static QIcon GetIcon(const QString& name, const QString& dir);
- static QPixmap GetPixmap(const QString& name, const QString& dir);
+ static QIcon GetIcon(std::string_view name, const QString& dir);
+ static QPixmap GetPixmap(std::string_view name, const QString& dir);
static QList<QPixmap> m_platforms;
static QList<QPixmap> m_countries;
diff --git a/Source/Core/DolphinQt/Settings/GameCubePane.cpp b/Source/Core/DolphinQt/Settings/GameCubePane.cpp
index ce45eb54a1..8ec5126f2f 100644
--- a/Source/Core/DolphinQt/Settings/GameCubePane.cpp
+++ b/Source/Core/DolphinQt/Settings/GameCubePane.cpp
@@ -440,7 +440,7 @@ void GameCubePane::LoadSettings()
bool have_menu = false;
- for (const std::string& dir : {USA_DIR, JAP_DIR, EUR_DIR})
+ for (const std::string dir : {USA_DIR, JAP_DIR, EUR_DIR})
{
const auto path = DIR_SEP + dir + DIR_SEP GC_IPL;
if (File::Exists(File::GetUserPath(D_GCUSER_IDX) + path) ||
diff --git a/Source/Core/UICommon/GameFileCache.cpp b/Source/Core/UICommon/GameFileCache.cpp
index 30bbca924b..a1b55b3614 100644
--- a/Source/Core/UICommon/GameFileCache.cpp
+++ b/Source/Core/UICommon/GameFileCache.cpp
@@ -45,7 +45,7 @@ GameFileCache::GameFileCache() : m_path(File::GetUserPath(D_CACHE_IDX) + "gameli
void GameFileCache::ForEach(std::function<void(const std::shared_ptr<const GameFile>&)> f) const
{
- for (const std::shared_ptr<const GameFile>& item : m_cached_files)
+ for (const std::shared_ptr<GameFile>& item : m_cached_files)
f(item);
}