This problem occured when writing in Delphi.
Here's my example code:
Code: Select all
type
TImpField = class(TObject)
...
...
end;
PImpField = ^TImpField;
============================================
procedure initFields;
var
pItem: PImpField;
begin
ImportList := TList.Create;
pItem^ := TImpField.Create;
if (pItem <> nil) then
begin
pItem^.Table := 'Project';
pItem^.Name := 'Name';
pItem^.Value := 'Testing';
ImportList.Add(pItem);
end;
end;
BUT: as soon as the end of procedure "initFields" is reached, an access violation is thrown - and to make things REALLY strange: The error-pointer sits on the last "end;" of the procedure.
[SOLUTION]
pItem was not instantiated correctly.
Replacing
Code: Select all
begin
ImportList := TList.Create;
pItem^ := TImpField.Create;
Code: Select all
begin
ImportList := TList.Create;
[b]new(pItem);[/b]
pItem^ := TImpField.Create;
solved it.