![]() |
Add element into object list erzeugt eine access violation
was ist denn an dem code sample unten falsch, warum kommt es hier zu einer AV beim Einfügen eines neuen Elements ?
Delphi-Quellcode:
type
/// <summary> /// read content between start search key and ending search key word /// </summary> TPContent = class InstanceType: String; text_startPos: Integer; text_StopPos: Integer; InstanceString: String; end; type TPList = class(TobjectList<TPContent>) private fInfoStrlst: TStringList; public constructor Create; destructor Destroy; override; procedure SavetoFile(aFilename: String); property InfoStrLst: TStringList read fInfoStrlst write fInfoStrlst; end; procedure TForm2.Button2Click(Sender: TObject); var aPlist: TPlist; aPContent: TPContent; i: Integer; begin aPlist := TPlist.Create; for i := 0 to 1000 do begin aPContent := TPContent.Create; aPContent.InstanceType := 'xxxxx'; aPContent.InstanceString := 'CCCCCCCC'; aPContent.text_startPos := 0; aPContent.text_StopPos := 0; aPlist.Add(aPContent); // hier tritt der AV Fehler auf end; end; Fehler
Delphi-Quellcode:
// Calculate the needed size of the heap object
t := PDynArrayTypeInfo( PByte(typeInfo) + PDynArrayTypeInfo(typeInfo).name ); elSize := t.elSize; |
AW: Add element into object list erzeugt eine access violation
inherited vergessen? :stupid:
Ist natürlich bissl doof, wenn alle Funktionen geheim sind und wir nix sehn. |
AW: Add element into object list erzeugt eine access violation
@ Danke & Volltreffer !
die alte version der Klasse war :
Delphi-Quellcode:
und da brauchte es keine Constructor in keine inherited :-)TPList = class(TobjectList<TPContent>) procedure SavetoFile(aFilename: String); end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 22:44 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz