Hi,
I have a strange situation going on in my app. I do objman.Save(aobj), then a objman.flush after altering 1 property. sometimes I get this message when calling flush:
"Project Project.exe raised exception class EListError with message 'Item not found'."
This is caused in the line where the oldstate is fetched ( Old := FObjects.GetOldState(Obj); )
which in turn calls Result := FMap.Items[GenerateKey(Entity)].OldState;
it only happens sometimes, I cannot figure out what triggers it. I can go 10 times without this error and then it happens, sometimes I can go 20 times without it happening.
What could cause this?
That could happen if you change a property that is part of the id of the object. This causes the object to "become" another object, so it cannot be found anymore in the manager. Maybe that's the case?
I can replicate this now by doing exactly te same thing, and the sixth time it fails! I never change the id of the object. It's a guid, I only once set on creation. It has Generator.none.
It looks like a memory problem. It doesn't happen on iOs with ARC, so I suspect it has something to do with memory management. I cannot see how though. I created a isolated testproject that seems to do exactly the same, but of course this does not fail, aarrrrgggg!
Looks like the problem is somewhere in my code. Will look into further.