Bug in ObjectManager's DoRemove

In the method DoRemove there's a bug concerning the trash variable. 



TObjectManager.DoRemove(Entity: TObject);

var
  Trash: TList<TObject>;
begin
  ...
  Trash := TObjectList<TObject>.Create();
  ...
end;


That should obviously be 


TObjectManager.DoRemove(Entity: TObject);

var
  Trash: TList<TObject>;
begin
  ...
  Trash := TList<TObject>.Create();
  ...
end;

Why? Are you getting any error with that code?

Yes, I was getting access violations upon the Trash.free, it got two references to objects that were already freed. Since it was created as a TObjectlist<T>, it tried to free those again, hence the AV.

Please post the full code or if better, send us a compilable, executable (local sqlite database) project that reproduces the problem. That piece of code is central in Aurelius object manager and it's been there since version 1, I might be wrong, but I think it's not the reason for your error. Be sure you are not destroying the objects yourself before. You shouldn't, since TObjectManager manages the entity instances and it destroys the objects removed from it, that's why that code is written like that.