Browse Source

Fix dangerous usage of vector iterator (Thanks cgreco)

adaptive-webui-19844
Christophe Dumez 14 years ago
parent
commit
7294cdafbf
  1. 15
      src/properties/trackerlist.cpp

15
src/properties/trackerlist.cpp

@ -321,18 +321,15 @@ void TrackerList::deleteSelectedTrackers(){ @@ -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…
Cancel
Save