creating 2 instances of a form getting "invalid pointer error" on Free
Posted on 2014-01-26
I want to do things the right way and I thought I was heading the right direction but it seems I am missing something.
I have address.pas which is a simple form with edit boxes.
I have Personnel.pas which uses 2 instance of form address.pas.
Each instances are created as follow: (pseudo code)
procedure TFormPersonnel.FormCreate(Sender: TObject);
FormResidentialAddress := TFormAddress.Create(Self);
FormPostalAddress := TFormAddress.Create(Self);
Problem occurs when I want to Free the 2 instances as follow:
procedure TFormPersonnel.FormDestroy(Sender: TObject);
I am getting an "invalid pointer error" , but if I remove either: FormResidentialAddress.Free; or FormPostalAddress.Free; it solves the problem.
What atrocity am I committing?