Re: How to get Interface reference counting in ATL
- From: "Brian Muth" <bmuth@xxxxxxxx>
- Date: Fri, 9 Jun 2006 14:53:33 -0700
"Jaime Stuardo" <JaimeStuardo@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:8E08CA9A-3A5F-4B4D-91A7-DB42DC6E68BA@xxxxxxxxxxxxxxxx
Hi Brian,
I have replaced all pointers by smart ones using your preference, but
nothing works now :-( strange things started to happen, unexplainable
crashes, processes don't dissappear when I destroy the instance of the
component, and so on.
Since I don't know when objects are finally released, I think that some
objects aren't released when it should be, or they are released when they
shouldn't be.
Smart pointers are there to assist the programmer. There is nothing magical
about what they do; they are completely deterministic. The main advantage is
that they will call Release automatically when they go out of scope. This is
good news, since if the variable has gone out of scope you clearly can't use
the underlying interface pointer any more, and COM rules dictate that
Release() should be called.
Most programmers find there may be a little "trickiness" when assigning
interfaces pointers to smart pointers, but if there is any uncertaintly,
simply single-step right into the constructor or assignment operator of the
smart pointer and you can see exactly what is going on.
As a final note, no one is forcing you to use smart pointers. It is my
personal preference but not necessarily yours. Using raw interface pointers
is perfectly fine. And more importantly, don't expect smart pointers to find
bugs in your program. You are going to have to do that yourself.
.
- References:
- Re: How to get Interface reference counting in ATL
- From: Alexander Nickolov
- Re: How to get Interface reference counting in ATL
- From: Jaime Stuardo
- Re: How to get Interface reference counting in ATL
- From: Brian Muth
- Re: How to get Interface reference counting in ATL
- From: Jaime Stuardo
- Re: How to get Interface reference counting in ATL
- Prev by Date: Re: How to get Interface reference counting in ATL
- Next by Date: Re: How to get Interface reference counting in ATL
- Previous by thread: Re: How to get Interface reference counting in ATL
- Next by thread: Re: How to get Interface reference counting in ATL
- Index(es):
Relevant Pages
|