Permalink
Browse files

Properly fix the iterator bug, oops.

  • Loading branch information...
hrydgard committed Aug 14, 2018
1 parent 404594d commit 75827004e17598d8eb2806a48ec8978b3a95a28c
Showing with 10 additions and 4 deletions.
  1. +10 −4 Core/Config.cpp
View
@@ -1211,11 +1211,14 @@ void Config::AddRecent(const std::string &file) {
return;
const std::string filename = File::ResolvePath(file);
for (auto iter = recentIsos.begin(); iter != recentIsos.end(); ++iter) {
for (auto iter = recentIsos.begin(); iter != recentIsos.end();) {
const std::string recent = File::ResolvePath(*iter);
if (filename == recent) {
// Note that the increment-erase idiom doesn't work with vectors.
iter = recentIsos.erase(iter);
// We'll add it back below.
} else {
iter++;
}
}
@@ -1230,10 +1233,13 @@ void Config::RemoveRecent(const std::string &file) {
return;
const std::string filename = File::ResolvePath(file);
for (auto str = recentIsos.begin(); str != recentIsos.end(); ++str) {
const std::string recent = File::ResolvePath(*str);
for (auto iter = recentIsos.begin(); iter != recentIsos.end();) {
const std::string recent = File::ResolvePath(*iter);
if (filename == recent) {
recentIsos.erase(str);
// Note that the increment-erase idiom doesn't work with vectors.
iter = recentIsos.erase(iter);
} else {
iter++;
}
}
}

1 comment on commit 7582700

@unknownbrackets

This comment has been minimized.

Show comment
Hide comment
@unknownbrackets

unknownbrackets Aug 18, 2018

Collaborator

Blarg, sorry. Now I can't remember why there are even two, they look the same...

-[Unknown]

Collaborator

unknownbrackets commented on 7582700 Aug 18, 2018

Blarg, sorry. Now I can't remember why there are even two, they look the same...

-[Unknown]

Please sign in to comment.