mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-27 03:39:39 +03:00
Fix dangerous usage of vector iterator (Thanks cgreco)
This commit is contained in:
parent
493499cded
commit
7294cdafbf
1 changed files with 6 additions and 9 deletions
|
@ -321,18 +321,15 @@ void TrackerList::deleteSelectedTrackers(){
|
|||
delete item;
|
||||
}
|
||||
// Iterate of trackers and remove selected ones
|
||||
std::vector<announce_entry> remaining_trackers;
|
||||
std::vector<announce_entry> trackers = h.trackers();
|
||||
std::vector<announce_entry>::iterator it = trackers.begin();
|
||||
while(it != trackers.end()) {
|
||||
int index = urls_to_remove.indexOf(misc::toQString((*it).url));
|
||||
if(index >= 0) {
|
||||
trackers.erase(it);
|
||||
urls_to_remove.removeAt(index);
|
||||
} else {
|
||||
it++;
|
||||
std::vector<announce_entry>::iterator it;
|
||||
for(it = trackers.begin(); it != trackers.end(); it++) {
|
||||
if(!urls_to_remove.contains(misc::toQString((*it).url))) {
|
||||
remaining_trackers.push_back(*it);
|
||||
}
|
||||
}
|
||||
h.replace_trackers(trackers);
|
||||
h.replace_trackers(remaining_trackers);
|
||||
h.force_reannounce();
|
||||
// Reload Trackers
|
||||
loadTrackers();
|
||||
|
|
Loading…
Reference in a new issue