summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2019-05-23 13:52:23 +0200
committerMarc Mutz <marc.mutz@kdab.com>2019-05-23 13:55:40 +0200
commitbc6ffcd0c583919b91cd0e41e1f29ff188fc617a (patch)
treedd149017cfe8d193e28fa6f1559969a9b0fee3fe /examples
parent5ef6e1fa546a87c1e35b11c9e8c670f8410f88b3 (diff)
Torrent example: Replace the last Java-style iterator with STL ones
Scope a previous iterator variable better so we can re-use 'it' as the iterator name. Change-Id: I46d239ad2d3646168408d1ef29ed74fd07bc663f Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/network/torrent/torrentclient.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/examples/network/torrent/torrentclient.cpp b/examples/network/torrent/torrentclient.cpp
index b4cbbb7a45..bddf3caa1a 100644
--- a/examples/network/torrent/torrentclient.cpp
+++ b/examples/network/torrent/torrentclient.cpp
@@ -874,8 +874,7 @@ void TorrentClient::removeClient()
// Remove the client from RateController and all structures.
RateController::instance()->removeSocket(client);
d->connections.removeAll(client);
- QMultiMap<PeerWireClient *, TorrentPiece *>::Iterator it = d->payloads.find(client);
- while (it != d->payloads.end() && it.key() == client) {
+ for (auto it = d->payloads.find(client); it != d->payloads.end() && it.key() == client; /*erasing*/) {
TorrentPiece *piece = it.value();
piece->inProgress = false;
piece->requestedBlocks.fill(false);
@@ -883,9 +882,12 @@ void TorrentClient::removeClient()
}
// Remove pending read requests.
- QMapIterator<int, PeerWireClient *> it2(d->readIds);
- while (it2.findNext(client))
- d->readIds.remove(it2.key());
+ for (auto it = d->readIds.begin(), end = d->readIds.end(); it != end; /*erasing*/) {
+ if (it.value() == client)
+ it = d->readIds.erase(it);
+ else
+ ++it;
+ }
// Delete the client later.
disconnect(client, SIGNAL(disconnected()), this, SLOT(removeClient()));