uses Classes, SysUtils;
type
TMyObject = class (TObject)
private
Fsl: TStringList;
public
constructor Create;
destructor Destroy; override;
end;
implementation
constructor TMyObject.Create;
begin
Fsl := TStringList.Create;
end;
destructor TMyObject.Destroy;
begin
FreeAndNil (Fsl);
inherited;
end;
I get an access violation when the TStringList is created in the constructor.
This only happens if Fsl is declared as a field of TMyObject. If it is for example a global var, everything works as usual.
What am I doing wrong?