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:
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:
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