From inside an event handler of the control itself, I would like to delete and free it.
A typical use case for TFmxObject.Release
, isn't it? However, it only seems to work under Windows, but not Android, and this method is now deprecated anyway.
I know, doesn't work is not a good problem description, but currently I'm not able to debug it under android. Under Windows, I see that the event handler continues correctly after the .Release
and after it finished, my log message inside my controls destructor is executed. Under Android, the application hangs.
When I use .Free
instead, it still works under Windows (destructor happens immediately, but the handler doesn't access the control after the free), and in Android there is no visible problem, but the destructor is never called, so I have a leak.
With .DisposeOf
the effect is the same as with .Release
- Windows ok, Android hangs.
I also tried MyParent.RemoveComponent(MyControl)
but it all didn't help.
What else do I have to do to release all references so that ARC can do its work? Or how else?