why aren't descendants of TInterfacedObject garbage collected?

后端 未结 3 552
臣服心动
臣服心动 2021-01-03 05:16

i have a class based on TInterfacedObject. i add it to TTreeNode\'s Data property.

TFacilityTreeItem=class(TInterfacedObject)
private
  m_guidItem:TGUID;
           


        
3条回答
  •  鱼传尺愫
    2021-01-03 06:11

    As dummzeuch said, you can get this to work with interfaces, but it takes some more code since the Data property of a TTreeNode is a pointer. For anyone wondering how to do that, this link has an example of how to do it for TListItem (it's pretty much the same for TTreeNode). You may also find it useful to read the section about interfaces and subsequent section about reference counting on that page.

提交回复
热议问题