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>
This commit is contained in:
parent
5ef6e1fa54
commit
bc6ffcd0c5
@ -874,8 +874,7 @@ void TorrentClient::removeClient()
|
|||||||
// Remove the client from RateController and all structures.
|
// Remove the client from RateController and all structures.
|
||||||
RateController::instance()->removeSocket(client);
|
RateController::instance()->removeSocket(client);
|
||||||
d->connections.removeAll(client);
|
d->connections.removeAll(client);
|
||||||
QMultiMap<PeerWireClient *, TorrentPiece *>::Iterator it = d->payloads.find(client);
|
for (auto it = d->payloads.find(client); it != d->payloads.end() && it.key() == client; /*erasing*/) {
|
||||||
while (it != d->payloads.end() && it.key() == client) {
|
|
||||||
TorrentPiece *piece = it.value();
|
TorrentPiece *piece = it.value();
|
||||||
piece->inProgress = false;
|
piece->inProgress = false;
|
||||||
piece->requestedBlocks.fill(false);
|
piece->requestedBlocks.fill(false);
|
||||||
@ -883,9 +882,12 @@ void TorrentClient::removeClient()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove pending read requests.
|
// Remove pending read requests.
|
||||||
QMapIterator<int, PeerWireClient *> it2(d->readIds);
|
for (auto it = d->readIds.begin(), end = d->readIds.end(); it != end; /*erasing*/) {
|
||||||
while (it2.findNext(client))
|
if (it.value() == client)
|
||||||
d->readIds.remove(it2.key());
|
it = d->readIds.erase(it);
|
||||||
|
else
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
|
||||||
// Delete the client later.
|
// Delete the client later.
|
||||||
disconnect(client, SIGNAL(disconnected()), this, SLOT(removeClient()));
|
disconnect(client, SIGNAL(disconnected()), this, SLOT(removeClient()));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user