TCollection.Delete, how come... question lazarus / 21-General ---------------------------------------------------------------------- cdbc · 2022-09-26 11:07 Hi How come that TCollection.Delete does not call TCollection.RemoveItem?!? It only frees the item and notifies observers. The slot remains in the collection. Excerpt from collect.inc: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TCollection.Delete(Index: Integer);Var  Item : TCollectionItem;begin  Item:=TCollectionItem(FItems[Index]);  Notify(Item,cnDeleting); //<----------  Item.Free;                     //<----------end;In it's private parts, we find TCollection.RemoveItem, which does the deleting/removing business: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TCollection.RemoveItem(Item: TCollectionItem); Var  I : Integer; begin  Notify(Item,cnExtracting);  I:=FItems.IndexOfItem(Item,fromEnd);  If (I<>-1) then    FItems.Delete(I);       //<-----------  Item.FCollection:=Nil;  //<-----------  Changed;end; It doesn't get called or somthing similar done, to remove the item. What happens if one deletes an item and then afterwards traverses the collection?!? Wouldn't that be an accident waiting to happen?!? Bug?!? Regards Benny ---------------------------------------------------------------------- PascalDragon · 2022-09-26 11:14 The destructor of TCollectionItem ensures that the item removes itself from the collection. RemoveItem only removes the item from the collection, but does not free the TCollectionItem itself (what Delete does). ---------------------------------------------------------------------- cdbc · 2022-09-26 11:36 Hi @PascalDragon: Thank you, the destructor part eluded me  Then all is fine and dandy  Regards Benny