> Some questions:
> 
> 
> for each objFile  in objFolder.Files
>   win.debug("   unicode handle: " ++ objFile.Name ++ " = " ++ 
> objFile.Name.ascii) ;; should be returned as handle to unicode string
> ; NOT necessary to release objects 
> ; objFile.release
> endfor
> 
> 
> Seem to work okay without release. 

There is a bug in foreach unless you have the latest exe (it is fixed in that 
exe which provides to callplugin service).  But if you have that latest exe, 
then foreach should work correctly, ie

1.  objFile will be allocated and treated as local if it is not allocated 
before the for each.

2.  each time objfile is assigned, the ppsv->ChangeRefHandle (terrible name!) 
service is called which will call any reference counter for the object, as per 
the help (in vec, I called it changeifhandle in the pproservices typedef  but 
it is same function)

Fomr the help:
ppsv->ChangeRefHandle is used in assignments.  First  the plugin calls it with 
second argument 1 to add a new reference for the new value.  Then it is called 
again with second argument 0 on the value which is being overwritten by the 
assignment (if any) to decrement the reference count for that value, it if is 
an object.

-------------------

> hanlde always the same, which suggests the for/each mechanism is >doing the 
> right thing.  I'll step through it in debugger at some >point to make sure.

Can I suggest you implement some kind of global debugging services for any 
object like
obj.__refs__
or some such which returns your internal ref count for the object.  Then 
win.debug counts as your go through for loops. 

> 
> My decrementRef callback function, it it's passed an invalid handle, does 
> nothing.  That seems right, because might happen if e.g. user
> DID release a handle explicitly 


I suspect the release should do nothing if you implement reference counting.  
Note that this is no release function for class-plugin objects and no 
localcopy.  If you get an invalid handle, it should be a bug in your code or 
mine.



>before your code (e.g. for/each code) tried to.  That sounds right.
> 
> Also: if I do this:
> 
> hVec[1] = hanToComObj
> 
> I assume your code bumps up the ref count via my incrementing >callback.  


Well, it is actually your code now (vec_set_internal) which calls 
ChangeIfHandle (ie ChangeRefHandle!!) which will then call the ref count 
management function you supply with ppsv->SetChangeRefCallback .


> I  bet ppsv->CallPlugin doesn't do anything about it either.  Assume >your 
> code handling assignment is where it happens, 

Yes, when a assignment to an ordinary varaible happens, the changerefhandle is 
called from within powerpro.exe.  


>and I have to do the same anywhere I copy a handle

If you are copying a handle, you should use changerefhandle both on the 
assigned object and on any object which it is overwriting.  In that order; see 
vec for sample and see the section on collection objects in the plugin help.  
Here I assume you are copying it to an com object.  If you are copying using 
setvar to a plain variable, powerpro handles the calls to changerefhandle.




> 
> Hmmm, what it I use ppsv->SetVar or the SetVar that comes down through 
> service parameters; does that do reference incrementing?

Yes.

> Does it check to see if variable I'm setting already has a handle in it, and 
> decrement if so?

It uses changerefhandle too.
>


Reply via email to