FMX TMetropolisUIListBoxItem Scrolling error

  

I am building an application using fmx where a TListbox adds TMetropolisUIListBoxItem using ini file. The problem is, while user scrolls the listbox, "Invalid Pointer Operation" error shows up. Here’s the code of adding TMetropolisUIListBoxItems.
MemINI := TMemINIfile.Create(System.IOUtils.TPath.GetFileNameWithoutExtension(paramstr(0))
+ ‘.ini’);
Alist := TStringlist.Create;
MemINI.ReadSections(Alist);
Setlength(Stu, Alist.Count);
for var I := 0 to Alist.Count – 1 do
begin
Stu[I] := TMetropolisUIListBoxItem.Create(ListBox1);
Stu[I].Description := MemINI.ReadString(Alist.Strings[I],
‘Notes’, ”);
Stu[I].SubTitle := MemINI.ReadString(Alist.Strings[I], ‘ID’, ”);
Stu[I].Title := Alist.Strings[I];
if fileexists(MemINI.ReadString(Alist.Strings[I], ‘Icon’,
Stu[I].Title)) then
Stu[I].Icon.LoadFromFile(includetrailingbackslash(GetCurrentdir) +
MemINI.ReadString(Alist.Strings[I], ‘Icon’, Stu[I].Title));
Stu[I].Parent := ListBox1;
end;
Alist.Free;
Memini.Free;

I don’t face an error if I have a few items and don’t have to scroll. It’s just when there are a lot of items in the list and the items need to be scrolled. User scrolls up/down and "Invalid Pointer Operation" shows up. The delphi debugger refers to TObject.free while throwing the error but I don’t see a reference of freeing something here.

Comments are closed.