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

> > It means that a handle isn't being freed.  Second time into script,
> > c\0x05_003 should be free, but it's not, plugin uses next free hanlde,  so 
> > c\0x05_004. 
> 
> Note from detailed steps in previous note that the above behaviour is 
> expected.  The foreach var will get freed by the setvar calling back to your 
> free routine, but this routine is after you have generated the handle.

More evidence:

local hCollectionFiles = objFolder.Files
for each objFile  in hCollectionFiles
  win.debug(" com handle: " ++ objFile ++ " ref cnt: " ;;+
    ++ objFile._refs__ ++  ", name: " ++ objFile.Name) 
endfor

win.debug(" hCollectionFiles refs: " ++ hCollectionFiles._refs__ )

hCollectionFiles shows ref count of _2_.  That seems weird.


Also at this point, after endfor
win.debug("com handle: " ++ objFile)  ;; objFile is null string!!

If I force the hCollectionFiles into non-existence with

hCollectionFiles.release

all's well, amnd I don't have ever-increasing handle numbers

> As a test and possible workaround, before generating a new handle (but after 
> confirming that there are more items in the collection) , setvar the foreach 
> variable to "".  This should free the old handle.  Or simply free it yourself 
> at the start.  By free I mean dec the ref count.

Do you add 1 to ref count of collections object when you start a 
for each loop?  If so, do you decrement at end?

Posted modified comPluginDemoScriptFileSysObjDotSyntaxForEachRefCnt.powerpro
with above changes
in my usual folder, if you want to try.




Reply via email to