fixed conditional erase exception

This commit is contained in:
Lauchmelder 2021-12-27 22:09:09 +01:00
parent e80cfee1fe
commit 36ba857b0d

View file

@ -19,10 +19,12 @@ namespace lol
void ObjectManager::ClearUnused()
{
for(const auto& [key, value] : objects)
for(std::map<unsigned int, std::shared_ptr<void>>::iterator it = objects.begin(); it != objects.end();)
{
if(value.unique())
objects.erase(key);
if (it->second.unique())
it = objects.erase(it);
else
it++;
}
}