I have a strange situation occurring and want to try to understand it.
First, some background. These are the relevant areas of my code:
TMediaListItem = record
procedure TMediaList.Add(AArtist, ATitle, AFileType, AFlags,
AFileName: string; ACredits: Integer);
SetLength(fItems, Length(fItems) + 1);
fItems[High(fItems)].Artist := AArtist;
fItems[High(fItems)].Title := ATitle;
fItems[High(fItems)].FileType := AFileType;
fItems[High(fItems)].Flags := AFlags;
fItems[High(fItems)].FileName := AFileName;
fItems[High(fItems)].Credits := ACredits;
fItems[High(fItems)].Jpeg := TJpegImage.Create;
procedure TMediaList.Delete(AIndex: Integer);
for I := AIndex to Length(fItems) -2 do
fItems[I] := fItems[I + 1];
fItems[High(fItems)].Jpeg.Free; // This is the problem line
SetLength(fItems, Length(fItems) -1);
To add an item to the MediaList I call the Add() method and then later
assign a jpeg to it:
When I want to delete a MediaList.Item I get an AV at 0 on the
I have done similar things in the past (not with TJpegImage).
From what I can understand of the D7 help, TJpegImage is reference
counted so I am guessing that has something to do with my problem.
If I remove the offending line I would imagine the potential for a memory
Does anyone have an idea of what I should do?