Questions tagged [tinterfacedobject]

TInterfacedObject is a base for simple classes implementating basic IInterface. It is defined in the System.pas unit.

9 questions
8
votes
7 answers

Reference-counting for objects

In my code I use a small data-storing class, which is created in different places. To avoid memory leaks and simplify things, I want to use reference counting, so I did type TFileInfo = class (TInterfacedObject, IInterface) and removed all my…
jpfollenius
  • 16,456
  • 10
  • 90
  • 156
7
votes
1 answer

Why does an instance of class(TInterfacedObject, IDropTarget) not auto free?

I'm implementing my IDropTarget based on: How can I allow a form to accept file dropping without handling Windows messages? The implementation by David works fine. however the IDropTarget (TInterfacedObject) object does not auto free, not even when…
zig
  • 4,524
  • 1
  • 24
  • 68
7
votes
3 answers

How do I implement two interfaces that have methods with the same name?

I am trying to declare a custom list of interfaces from which I want to inherit in order to get list of specific interfaces (I am aware of IInterfaceList, this is just an example). I'm using Delphi 2007 so I don't have access to actual generics…
Steve Riley
  • 144
  • 2
  • 10
5
votes
3 answers

Why does the compiler say the implementation "differs from the previous declaration" when they look identical?

i have two units, first one, my interface: use personas interface type Tllave = array[0..31] of byte; Tdatos = array of byte; ImyInterface = interface(IInterface) function nombre : string; function edad : integer; procedure…
erick
  • 59
  • 2
  • 8
4
votes
3 answers

why aren't descendants of TInterfacedObject garbage collected?

i have a class based on TInterfacedObject. i add it to TTreeNode's Data property. TFacilityTreeItem=class(TInterfacedObject) private m_guidItem:TGUID; m_SomeOtherNode:TTreeNode; public end; i create many instances of this object & had assumed…
X-Ray
  • 2,816
  • 1
  • 37
  • 66
2
votes
1 answer

Is TInterfacedObject autofree thread safe in Delphi?

Is TInterfacedObject._Release and TInterfacedObject._AddRef thread safe? I can see FRefCount is thread safe, but Destroy is not protected by locks or something else. function TInterfacedObject._Release: Integer; begin Result :=…
qgi
  • 25
  • 4
1
vote
2 answers

Does class(TInterfacedObject) need a destructor in Delphi?

I run in this situation where Destroy() is never called. unit Unit2; interface type // Interface ITest = Interface(IInterface) function IsTrue() : Boolean; end; TmyClass = class(TInterfacedObject, ITest) public // Interface…
ToKa
  • 80
  • 7
1
vote
0 answers

memory leak when using TInterfacedObject as Interface reference in dependent objects

Introduction I found out my code leaks memory of an instance of a TInterfacedObject that I keep as a Interface reference. Although I reset the reference variable to nil after usage, it remains alive. The leaked object is of class TMasterObject,…
1
vote
0 answers

XE8 64 bit Debugging object derived from TInterfacedObject

Suppose I have a class TCar which supports interface ICar and is derived from TInterfacedObject. program Project1; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils; type ICar = interface …