mkudra
asked on
AV when creating nested object when creating TStringList
This is actually probably a simple problem, but i am even MORE simple ...
When creating a TTargetMap as declared and defined in the unit below, I receive an UNWANTED AV in:
constructor TScript.Create;
....
AV ==> ScriptList := TstringList.Create;
Source:
unit TMTest;
interface
uses
Classes, Forms;
type
TScript = class(TObject)
private
protected
public
ScriptList: TStringList;
ScriptImage: Integer;
ScriptStep: Integer;
constructor Create;
destructor Destroy; override;
end; // TScript
TTargetMap = class(TObject)
private
protected
public
TargetList: TStringList;
Parent: TForm;
Script: TScript;
constructor Create(ParentForm: TForm);
destructor Destroy; override;
end; // TTargetMap
implementation
constructor TScript.Create;
begin
inherited Create;
ScriptList := TstringList.Create;
ScriptStep := -1;
ScriptImage := -1;
end; // function TScript.Create
destructor TScript.Destroy;
begin
inherited Destroy;
ScriptList.Free;
end; // function TScript.Destroy
constructor TTargetMap.Create(ParentFo rm: TForm);
begin
inherited Create;
Parent := ParentForm;
TargetList := TStringList.Create;
Script.Create;
end; // function TTargetMap.Create
destructor TTargetMap.Destroy;
begin
inherited Destroy;
Script.Free;
end; // function TTargetMap.Destroy
end. // unit TMTest
When creating a TTargetMap as declared and defined in the unit below, I receive an UNWANTED AV in:
constructor TScript.Create;
....
AV ==> ScriptList := TstringList.Create;
Source:
unit TMTest;
interface
uses
Classes, Forms;
type
TScript = class(TObject)
private
protected
public
ScriptList: TStringList;
ScriptImage: Integer;
ScriptStep: Integer;
constructor Create;
destructor Destroy; override;
end; // TScript
TTargetMap = class(TObject)
private
protected
public
TargetList: TStringList;
Parent: TForm;
Script: TScript;
constructor Create(ParentForm: TForm);
destructor Destroy; override;
end; // TTargetMap
implementation
constructor TScript.Create;
begin
inherited Create;
ScriptList := TstringList.Create;
ScriptStep := -1;
ScriptImage := -1;
end; // function TScript.Create
destructor TScript.Destroy;
begin
inherited Destroy;
ScriptList.Free;
end; // function TScript.Destroy
constructor TTargetMap.Create(ParentFo
begin
inherited Create;
Parent := ParentForm;
TargetList := TStringList.Create;
Script.Create;
end; // function TTargetMap.Create
destructor TTargetMap.Destroy;
begin
inherited Destroy;
Script.Free;
end; // function TTargetMap.Destroy
end. // unit TMTest
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You are very welcome.
Thanks for the points,
Russell
ASKER