Skip to content

Commit

Permalink
Merge pull request #1436 from LGM-Doyle/fix_bug_osx_intermitent_crash…
Browse files Browse the repository at this point in the history
…_when_experimetors_active

Fix crash caused by erasing map elements while iterating in System.cpp.
  • Loading branch information
geoffthemedio committed Mar 24, 2017
2 parents b9f084e + a32c82e commit 3cef249
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions universe/System.cpp
Expand Up @@ -162,10 +162,15 @@ void System::Copy(std::shared_ptr<const UniverseObject> copied_object, int empir
// to exist any more

// remove previously known lanes that aren't currently visible
for (std::map<int, bool>::value_type& entry : this->m_starlanes_wormholes) {
int lane_end_sys_id = entry.first;
if (visible_lanes_holes.find(lane_end_sys_id) == visible_lanes_holes.end())
this->m_starlanes_wormholes.erase(lane_end_sys_id);
for (auto entry_it = m_starlanes_wormholes.begin(); entry_it != m_starlanes_wormholes.end();
/* conditional increment in deleting loop */)
{
int lane_end_sys_id = entry_it->first;
if (visible_lanes_holes.find(lane_end_sys_id) == visible_lanes_holes.end()) {
entry_it = m_starlanes_wormholes.erase(entry_it);
} else {
++entry_it;
}
}
}
}
Expand Down

0 comments on commit 3cef249

Please sign in to comment.