entitylump: Fix behavior of append (#1836)
This change ensures that the iterator values used by `std::distance` is correct. Having the emplace within leads to the possibility of `m_Entities.begin()` being invalidated due to reallocations.
This commit is contained in:
parent
568da23c96
commit
855ece1d3b
@ -122,10 +122,8 @@ void EntityLumpManager::Insert(size_t index) {
|
||||
}
|
||||
|
||||
size_t EntityLumpManager::Append() {
|
||||
return std::distance(
|
||||
m_Entities.begin(),
|
||||
m_Entities.emplace(m_Entities.end(), std::make_shared<EntityLumpEntry>())
|
||||
);
|
||||
auto it = m_Entities.emplace(m_Entities.end(), std::make_shared<EntityLumpEntry>());
|
||||
return std::distance(m_Entities.begin(), it);
|
||||
}
|
||||
|
||||
size_t EntityLumpManager::Length() {
|
||||
|
Loading…
Reference in New Issue
Block a user