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

> > Do you add 1 to ref count of collections object when you start a 
> > for each loop?  If so, do you decrement at end?
> >
> For each is supposed to work as follows.
> 
> 1.  Powerpro.exe calls your foreach callback.
> 
> 2.  Your plugin calls setvar on the foreach variable to overwrite its current 
> value with a the next result in the enumeration.
> 
> 3.  setvar calls changerefifhandle which calls your free function if the 
> variable being set already contains a handle (note:  the old value of the for 
> each variable is what I mean, not the new value being set).
> 
> 4.  Your plugin returns from doforeach.
> 
> 5.  Processing in powerpro.exe now calls changerefifhandle on the foreach 
> variable, which will call back to your plugin to increment ref count.
 
>From what I can see, handles going into and overwritten in foreach variable 
>are behaving as they should.  It's the handle to the collection that's got 
>annoyed.

> I won't have time to track your script execution from powerpro.exe end until 
> at least late in the weekend .  If you wanted to play with it before then, 
> you could insert traces in your plugin in the foreach, free, and ref 
> increment callbacks, and so see if they are called as expected.  You could 
> include the scriptline number in the trace (getvar("scriptline")) to help 
> relate the trace to the executing script.

Okay

But without going into debugger, seems to happen on the for each:

local objFile            
local hCollectionFiles = objFolder.Files 

;line below returns 1
win.debug(" hCollectionFiles refs: " ++ hCollectionFiles._refs__ )  

for each objFile  in hCollectionFiles
; line below returns 2
  win.debug(" hCollectionFiles refs: " ++ hCollectionFiles._refs__ )
endfor
;line below returns 2
win.debug(" hCollectionFiles refs: " ++ hCollectionFiles._refs__ )


> I don't know how the ref count for the enumeration handle got set to two.  I 
> or you would need to do some tracing to find out at what script line that is 
> happening.

I won't get back to my compiler now til Monday.  



Reply via email to