yangyxd / FMXUI

FMX跨平台基础UI库
MIT License
261 stars 96 forks source link

Access violations on freeing of dynamically created TListViewEx #31

Closed helgovic closed 3 years ago

helgovic commented 3 years ago

There seams to be a bug here. When creating like this.

               LVDir.FList := TList<TDirectoryDataItem>.Create;
               LVDir.FAdapter := TDirectoryDataAdapter.Create(LVDir.FList);
               LVDir.FListView := TListViewEx.Create(Layout2);
               LVDir.FListView.Parent := Layout2;
               LVDir.FListView.Align := TAlignLayout.Client;
               LVDir.FListView.EnablePullRefresh := False;
               LVDir.FListView.EnablePullLoad := False;
               LVDir.FListView.OnItemClickEx := LVDirectoryItemClickEx;
               LVDir.FListView.OnItemClick := LVDirectoryItemClick;
               LVDir.FListView.AllowItemClickEx := True;
               LVDir.FListView.OnClick := LVDirectoryClick;
               LVDir.FListView.Adapter := LVDir.FAdapter;

and freeing like this:
           LVDir.FListView.DisposeOf;
           LVDir.FList.DisposeOf;
           LVDir.FAdapter.DisposeOf;
KngStr commented 3 years ago

FAdapter is interface. You do not need to free it.

You can do this way

           LVDir.FListView.Adapter :=nil;
           LVDir.FAdapter :=nil;
           LVDir.FList.DisposeOf;
           LVDir.FListView.DisposeOf;
helgovic commented 3 years ago

ok, works