As operator on an interface increment the refcount by two
Original Reporter info from Mantis: syfre
-
Reporter name:
Original Reporter info from Mantis: syfre
- Reporter name:
Description:
Using implicit cast between object and interface :
obj := TmyObjectByRefCount.Create; //refcount = 1
intf := obj; //refcount = 2
Using As operator :
obj := TmyObjectByRefCount.Create; //refcount = 1
intf := obj as ImyInterface; //refcount = 3
I suspect the reason is As operator used one local variable which is dereferenced at the end of the block; anyway this may have edge effects when porting from Delphi
Steps to reproduce:
Make a dunit project with the join unit
Mantis conversion info:
- Mantis ID: 21460
- Version: 2.6.1
- Fixed in version: 3.0.0