Link to home
Start Free TrialLog in
Avatar of mkudra
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(ParentForm: 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

ASKER CERTIFIED SOLUTION
Avatar of Russell Libby
Russell Libby
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mkudra
mkudra

ASKER

Thanks, Russell!  Well worth the points to make forward progress!

You are very welcome.

Thanks for the points,
Russell