aboutsummaryrefslogtreecommitdiffstats
path: root/gui
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2018-08-02 08:32:16 +0200
committerMiodrag Milanovic <mmicko@gmail.com>2018-08-02 08:32:16 +0200
commit86a36ceeef728413a213fa7702d07cf4a6c5298b (patch)
treed35acb090917fa71e35df61baa30453a5961914b /gui
parent97b16c6a5f81ac7643dfe5d811628ec076a3fc7d (diff)
downloadnextpnr-86a36ceeef728413a213fa7702d07cf4a6c5298b.tar.gz
nextpnr-86a36ceeef728413a213fa7702d07cf4a6c5298b.tar.bz2
nextpnr-86a36ceeef728413a213fa7702d07cf4a6c5298b.zip
Properly delete element from unordered_map
Diffstat (limited to 'gui')
-rw-r--r--gui/treemodel.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/gui/treemodel.cc b/gui/treemodel.cc
index 900d5101..33dd6a96 100644
--- a/gui/treemodel.cc
+++ b/gui/treemodel.cc
@@ -70,12 +70,14 @@ void IdStringList::updateElements(Context *ctx, std::vector<IdString> elements)
}
// For any elements that are in managed_ but not in new, delete them.
- for (auto &pair : managed_) {
- if (element_set.count(pair.first) != 0) {
- continue;
+ auto it = managed_.begin();
+ while (it != managed_.end()) {
+ if (element_set.count(it->first) != 0) {
+ ++it;
+ } else {
+ it = managed_.erase(it);
+ changed = true;
}
- managed_.erase(pair.first);
- changed = true;
}
// Return early if there are no changes.