>
> Problem is: forcing ref count to zero by assigning handle to null string
> didn't seem to let go of the handle, because handle number kept increasing on
> subsequent runs. However, will follow advise below and see what happens.
I don't really understand the situation.
How does handle number relate to ref count?
More comments below, but can I suggest you try a test without for each
something like.
local objFile
local hCollectionFiles = objFolder.Files
objfile =hCollectionFiles.getnext //I don;t know right service
//include trace or win.debug(..._refs__) in your plugin to see if ref count is
incremented or win.debug on refs
// repeat above lines several time and make sure handles are released as
expected
>
> Off topic:
>
> Seems we may be able to continue to use VC++ 6 using visual studio 2008.
> Dunno if the Express versions of the latter count.
Well, I use VC 5, but this is nice to know.
> > >
> > > local objFile
> > > local hCollectionFiles = objFolder.Files
> > > for each objFile in hCollectionFiles
> > > win.debug(" com handle: " ++ objFile ++ " ref cnt: " ++ objFile._refs__
> > > ++ ", name: " ++ objFile.Name)
> > > endfor
> > > objFile = ""
> > > hCollectionFiles = ""
Is the output you are showing in full note related to the win.debug statement.
It looks different?
In any event, here is what I think should happen.
1. objFolder.files creates a new handle. Plugin sets its reference count to
zero.
2. Assignment to hCollectionFiles cases powerpro.exe to call your
refcallback(...,1) and you increment that handle's ref count to 1.
3. for each initialization calls plugin's foreach callback with variable
""objFile" and the handle in hCollectionFiles. Plugin generates a handle
representing first item in enumeration, sets its ref count to zero, and call
setvar to assign it to objfile. after return for for each, foreach processor
calls your refcallback(...,1) to add reference to this handle.
4. For each subsequent iteration in the loop, foreach processor calls you with
"objFile". Plugin calls setvar. That will call your free callback on the old
handle value in objFile, which will decrement its ref count. Its ref count
will now be zero and that old value is released. Then after you return from
your foreach routine, PowerPro call will your refcallback(...,1) to add a ref
to new handle, making its ref count 1.
5. Note that, at end of for loop, ref count to last item returned in
enumerator is still 1 and that it's handle is in objFile.
6. Assignment of "" to objFile should call your free callback on that last
handle value, causing its ref count to go to zero and it to be released by your
plugin.
7. Assignment of "" to hCollectionFiles should call free callback for that
handle, causing its ref count to go to zero and you to release it.
Can you insert trace code or run under debugger to see if that is how your
plugin is being called for for each processing?