Unexpected failure of custom registered Reverter using TJSONUnMarshal

ぃ、小莉子 提交于 2019-12-06 05:19:30

rttiField.SetValue(Data, TValue.Empty); simply overrides the field value because as the name implies it's a field, not a property with get / set methods. The destructor of TStringList is not called due to simple pointer assignment.

The solution here is to declare a property:

TDataWithList = class
  ...
  strict private
    theList: TStringList;
    ...
  public
    property Data: TStringList read ... write SetData
    ...
end;

TDataWithList.SetData(TStringList aValue);
begin
  theList.Assign(aValue);
end;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!