Assign temporary data to a variable

This is mainly to avoid dangerous code pattern: getting an iterator on a
temporary object. Previously `data()` returns a const reference so the
code wasn't doing any harm.
This commit is contained in:
Chocobo1 2022-04-05 11:42:18 +08:00
parent 16bc0531f4
commit b9b2ed64f9
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C

View File

@ -717,7 +717,8 @@ void TorrentsController::addAction()
}
}
for (auto it = data().constBegin(); it != data().constEnd(); ++it)
const DataMap torrents = data();
for (auto it = torrents.constBegin(); it != torrents.constEnd(); ++it)
{
const nonstd::expected<BitTorrent::TorrentInfo, QString> result = BitTorrent::TorrentInfo::load(it.value());
if (!result)