Araq, my recent idea was to replace above code with
    
    
    proc `procName`(self:  `wt`;  p: proc (self: `wt`, arg: `at`); a: `at`) =
          when compiles(GC_ref(a)):
            GC_ref(a)
            `scName`(self, `procNameCdecl`, cast[pointer](a))
          else:
            var ar: ref `at`
            new(ar)
            deepCopy(ar[], a)
            `scName`(self, `procNameCdecl`, cast[pointer](ar))
        `procName`(`widget`, `p`, `arg`)
    

For this example the GC_ref() part is executed and GC_ref() crash. May it crash 
because a is a string literal and not a var? I hope at least the deepCopy part 
is OK.

Reply via email to