On Wed, Aug 10, 2016 at 11:08 AM, Tony Whyman <tony.why...@mccallumwhyman.com> wrote: > On 10/08/16 15:05, Marco van de Voort wrote: >> >> The way how Tony passes owner is wrong and that messes up reference >> counting. >> >> If in the test he would do TMyclass.Create(Tsomeclass.create); it >> probably >> would be ok. > > > But in my test, the code reads: > > Intf := TMyClass.Create(TDelegateClass.Create); > > So, why didn't this work?
+1 Is the same as Michael wrote. [off] Tony, You need to be careful when you use Interfaces and constructions like above. Using constructions like that, you always need to remember: "Now I need a local variable to the compiler do the refcount..." "Here isn't necessary, because the argument is an interface type variable..." ...and so on. For this "problem" I have my own pattern. I wrote about it here http://objectpascalprogramming.com/posts/interfaces-e-o-metodo-estatico-new/ I write in Portuguese, but you can translate easily. [/off] Marcos Douglas _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal