Re: Interface Question
- From: "Bjørge" <bjorge@xxxxxxx>
- Date: Tue, 10 Oct 2006 23:54:40 +0200
Hans-Peter Diettrich wrote:
Rob Kennedy wrote:
But note that you can't *fully* disable reference counting. You can
change _Release to not destroy the object, but you can't tell the
compiler not to call _AddRef and _Release at all.
Correct.
So if you free the
object by calling Free, you need to be certain that there are no
dangling interface references for that object. If there are, then
_AddRef or _Release will eventually be called for the object that has
already been destroyed, and that's the same problem you have even if
you _don't_ "disable" reference counting.
Just _AddRef and _Release cannot cause problems, because the
non-counting versions don't access the object. Calling other methods
may cause trouble, of course.
Yes, they allways do, because method calls are resolved through VMT's. It
means you'll have a hard time destroying objects if they're still referenced
as interfaces.
Not all implementations use interface's reference counting for lifetime
control - e.g. MS Excel won't let you keep a reference to a work*** if its
owner workbook is closed. You actually have to nil out all references to
sheets before you close the workbook. Dereferencing the workbook, in its
turn, won't close it either.
--
Bjørge
.
- References:
- Interface Question
- From: alanglloyd@xxxxxxx
- Re: Interface Question
- From: Maarten Wiltink
- Re: Interface Question
- From: Hans-Peter Diettrich
- Re: Interface Question
- From: Maarten Wiltink
- Re: Interface Question
- From: Hans-Peter Diettrich
- Re: Interface Question
- From: Rob Kennedy
- Re: Interface Question
- From: Hans-Peter Diettrich
- Interface Question
- Prev by Date: Re: Interface Question
- Next by Date: Re: Interface Question
- Previous by thread: Re: Interface Question
- Next by thread: Re: Interface Question
- Index(es):