--- In [email protected], "brucexs" <bruc...@...> wrote:

> >   pVecServices->create_vet(....,pszNewVecHanBuff);
> > //got new vec now
> > //later; put a com handle in iNdx'th eelement of vector
> >   pVecServices->set_vec(pszNewVecHanBuff, iNdx, 
> >            pszNewCommHanBuff);

> > In this case I can absolutely guarantee that vector element iNdx had 
> > nothing in it before I called pVecServices->set_vec, since vec is clean 
> > shiny new.  If I understand ppsv->changerefhandle, now no chance I'm 
> > overwritting something that needed ref counting.
 
> 
> It was not the element of the vector, it was the handle to the vector itself 
> I was thinking about.  If you assign it to a plain variable using setvar, 
> then no issue, powerpro.exe handles.  But if you store the result in an 
> object, then in theory you should call changerefhandle on it.   

Sorry, I'm being dense, or not communicating well.

The "it" I should in theory call changerefhandle on is the vec object -- the 
container?  Just to be absolutely clear: I'm storing a (new) handle to a COM 
object in a vector element.  Why does that (in theory) require that I call 
changerefhandle on the vec handle?


> If vec was referenced counted, you could not have to worry about local copy 
> and you could do stuff like this, fwiw:
> 
> function ...
> local myvec=vec.create (...
> global noGoodReason = myvec
> quit
 
> Without ref counting, the vector gets freed when local myvec is released, 
> even though global still is using it.  Not sure if something analogous could 
> ever happen in your code (if vec is ever made to use ref counting).

Okay, I understand that if vec supported ref counting, when I just before I 
returned the vec handle to caller I should call changerefhandle on it, no 
matter what I'd put in various vector elements.  

But wait, isn;t that something done by your ref counting stuff, because it 
woudl go like this:

local hVecOfData = hToRecordSet.getRows()

surely your code is checking to see if it should up the reference count for 
hVecOfData when you process that assignment?  So if you do it, why do I have to 
do it?

Now, back to the (new) com object handle placed in one of vec's elements.  
That's not a problem, cause as you've already pointed out, your vec code will 
notice it's a handle being assigned and do the right thing (up it's ref count).

So by my count, I don;t have to do anything?

But, like I said, I'm being dense.  Enlighten me?



Reply via email to