Hello,  FPC developers' list.

We are preparing a next lazarus version and our users are heavily testing thing. One bug report let me found one error which is not a lazarus error, but fpc. This error happen because we used TObjectList to store bitmaps in a list.

TObjectList is a useful thing - we dont need to think about object destroying. They will be destroyed on deleting from the list. And everyting works except next call: AList[AIndex] := NewObject

I attached a test projects which shows a bug.

But in few words this bug happen due to double object destroying:
1. In TObjectList.SetItem (this is *not correct* place to destroy)
2. In TObjectList.Notify (this is *correct* place to destroy)

A solution is simple: remove everything from TObjectList.SetItem except Put call.

--
Best regards,
Paul Ishenin.
program fpc_object_list_bug;
{$mode objfpc}{$H+}
uses
  Contnrs;
var
  List: TObjectList;
begin
  List := TObjectList.Create(True);
  List.Add(TObject.Create);
  List[0] := TObject.Create; // crash here :)
  List.Free;
end.

_______________________________________________
fpc-devel maillist  -  [email protected]
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to