summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-02-07 13:52:50 +0100
committerMarc Mutz <marc.mutz@qt.io>2023-02-08 08:37:21 +0100
commit44933343937d7a6d9f6afe1f8e0b0f93a387b100 (patch)
treefbceed74dde26105203aa56067137f10b69abde4 /examples
parent35b94f8b4349581c548b7aac2e858750072efa19 (diff)
savegame ex.: use ranged instead of indexed loopsHEADdev
Modernizes the code, and fixes qsizetype/int mismatch. Task-number: QTBUG-108857 Pick-to: 6.5 6.4 6.2 Change-Id: Id4262ee0bcb673d62135a81c30976903eef3e5e2 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/corelib/serialization/savegame/game.cpp4
-rw-r--r--examples/corelib/serialization/savegame/level.cpp4
2 files changed, 4 insertions, 4 deletions
diff --git a/examples/corelib/serialization/savegame/game.cpp b/examples/corelib/serialization/savegame/game.cpp
index f66e8553f9..21dedf9482 100644
--- a/examples/corelib/serialization/savegame/game.cpp
+++ b/examples/corelib/serialization/savegame/game.cpp
@@ -121,8 +121,8 @@ void Game::read(const QJsonObject &json)
QJsonArray levelArray = json["levels"].toArray();
mLevels.clear();
mLevels.reserve(levelArray.size());
- for (int levelIndex = 0; levelIndex < levelArray.size(); ++levelIndex) {
- QJsonObject levelObject = levelArray[levelIndex].toObject();
+ for (const QJsonValue &v : levelArray) {
+ QJsonObject levelObject = v.toObject();
Level level;
level.read(levelObject);
mLevels.append(level);
diff --git a/examples/corelib/serialization/savegame/level.cpp b/examples/corelib/serialization/savegame/level.cpp
index 04edadf7f6..c2f88c3434 100644
--- a/examples/corelib/serialization/savegame/level.cpp
+++ b/examples/corelib/serialization/savegame/level.cpp
@@ -35,8 +35,8 @@ void Level::read(const QJsonObject &json)
QJsonArray npcArray = json["npcs"].toArray();
mNpcs.clear();
mNpcs.reserve(npcArray.size());
- for (int npcIndex = 0; npcIndex < npcArray.size(); ++npcIndex) {
- QJsonObject npcObject = npcArray[npcIndex].toObject();
+ for (const QJsonValue &v : npcArray) {
+ QJsonObject npcObject = v.toObject();
Character npc;
npc.read(npcObject);
mNpcs.append(npc);