Thema: Delphi Array Access Violation

Einzelnen Beitrag anzeigen

Benutzerbild von DeluxXx
DeluxXx

Registriert seit: 3. Jul 2006
92 Beiträge
 
#1

Array Access Violation

  Alt 28. Jan 2008, 21:00
Hab ein Problem mit dem Zugriff auf die Attribute in einem Array .
Delphi-Quellcode:
private
VideoItemlist : array of TVideoItem ;
//...
implementation
//..
procedure TForm1.btAddToArray(Sender: TObject);
begin
 for i:=0 to ... -1 do
  begin
    //einlesen der werte
    //...
   setLength(VideoItemList,length(VideoItemList)+1) ;
   // in array schreiben
    VideoItemList[I] := TVideoItem.Create(lvVideos,Titel,Description,Rating) ;
  end ;
end;
procedure TForm1.auslesen() ;
begin
  Statusbar.Panels[0].Text := VideoItemList[0].getUrl ;
end;

end;
wenn ich jetzt versuche innerhalb der Methode btAddToArray auf das Item im Array zuzugreifen
klappt das Wunderbar . Jedoch nicht mehr in der Methode auslesen , ich versuche aber nicht auf ein Item zuzugreifen das nicht existiert (per länge des arrays überprüft). Kann es sein das der Speicher jedes mal freigegeben wird sobald ein neues Item hinzugefügt wurde ?
Edit hier noch das meiste von der Klasse TVideoItem
Delphi-Quellcode:
type TVideoItem = class
  private
    ltitel : String ;
    lRating : String ;
    lDescription : String ;
    lUrl : String ;
    lThumbnails : TThumbnaillist;
    lListItemIndex : Integer ;
  public
    property titel : String read ltitel write ltitel ;
    property Description : String read lDescription write lDescription ;
    property Url : String read lUrl write lUrl ;
    property Thumbnails : TThumbnaillist read lThumbnails write lThumbnails;
    property Rating : String read lRating write lRating ;
    function getUrl(): String ;
  published
    Constructor Create(listview : TListview;myTitel,myDescription : String;myRating : String);
  end;

implementation

 Constructor TVideoItem.Create(listview : TListview;myTitel,myDescription : String;myRating : String);
 var
 ListItem : TListItem ;
 begin
    lListItemIndex := listview.Items.Count ;
    Listitem := listview.Items.Add ;
    ListItem.Caption := '' ;
    Listitem.SubItems.Add(myRating) ;
    self.Rating := myRating ;
    ListItem.Subitems.Add(myTitel) ;
    self.titel := Titel ;
    ListItem.Subitems.Add(myDescription) ;
    self.Description := myDescription ;
 end;
If debugging is the process of removing bugs, then programming must be the process of putting them in.
  Mit Zitat antworten Zitat