Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2004-04

TCollection.Add

1 message · 1 person ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Taj Morton

Hello Everybody,
I must be missing something...donno. Whenever I try to add an item to a TCollection, it errors out.

function TDepsList.Add(const Name: string; VerOperator: TVerOper;
Version:String): TDepsItem;
begin
  Result := inherited Add as TDepsItem; <-- Crashes here
  Result.SetName(Name);
  Result.SetVersionOperator(VerOperator);
  Result.SetVersion(Version);
end;
Definition of TDepsItem:
TDepsItem = class(TCollectionItem)
    private
      FName: String;
      FVersion: String;
      FVerOperator: TVerOper;
      procedure SetName(Value: String);
      procedure SetVersion(Value: String);
      procedure SetVersionOperator(Value: TVerOper);
    public
      property Name: string read FName write SetName;
      property Version: string read FVersion write SetVersion;
      property VersionOperator: TVerOper read FVerOperator write
SetVersionOperator;
  end;

It errors with:
An unhandled exception occurred at 0x08053357 :
EACCESSVIOLATION : Access violation
0x08053357
0x08060686 TDEPSLIST__ADD, line 178 of package.pp 0x0806138B TPACKAGE__READDEPS, line 353 of package.pp 0x6F76003B
Segmentation fault

Any ideas why?

Thanks,

Taj "Never memorize something that you can look up." --Albert Einstein