Hello all, I have a class that has a generic list and a dynamic array which holds interfaced objects (interface references to objects).
Hello all, I have a class that has a generic list and a dynamic array which holds interfaced objects (interface references to objects).
The generic list is freed at the class destructor.
Does anyone know if the interface reference count of the interfaced objects is set to zero before/or when the generic list is freed and when the dynamic array is about to go out of scope or do I have to set the interface reference to nil to reduce the reference count.
The generic list is freed at the class destructor.
Does anyone know if the interface reference count of the interfaced objects is set to zero before/or when the generic list is freed and when the dynamic array is about to go out of scope or do I have to set the interface reference to nil to reduce the reference count.
Instead of describing your code show it. I should have known better than to have attempted to answer. Your question would be trivial to answer if you could ask it clearly.
ReplyDeleteIf you put interfaces, strings or dynamic arrays into a TList their refcount is being increased and when you remove them or the list is being destroyed they are being decreased. If I remember correctly the destructor of a TList calls Clear.
ReplyDeleteP.S. Before any nitpicker chimes in, yes, technically on interfaces there are _AddRef and _Release calls, so if you have non reference counted implementations behind the interfaces it does nothing.
Put a breakpoint in class destructor of that interface and see for yourself if it's called when the array go out of scope.
ReplyDeleteDon't lose your time waiting for answers. Test yourself how it works. You will learn more this way.