Download

TMap remove actor key problem

TMap<TSoftObjectPtr, FValue> AMap;
for (auto ItRemove = AMap.CreateIterator(); ItRemove; ++ItRemove)
{
if ((ItRemove.Key().IsValid())
{
if (Key.IsValid())
{
Key->Destroy();
}
ItRemove.RemoveCurrent();
break;
}
}

In some case, when i destroy my actor key, the AMap will remove the pair automatically, so when next ItRemove.RemoveCurrent(); was executed, my program will crash, but in other case, when i destroy my actor key, the AMap will not remove that pair, i don’t know why tmap remove the pair when the actor key was destroy?

pls help me, thx