TFmxObject.Release
uses TThread.ForceQueue
internally, and that’s currently broken under Android (see discussion above).
As a workaround, a working cross-platform version for releasing an object from its event handler would be
procedure TForm.CloseBtnClick(Sender: TObject);
begin
Parent := nil;
TThread.CreateAnonymousThread(
procedure
begin
TThread.Synchronize(nil,
procedure
begin
Self.DisposeOf;
end);
end).Start;
end;
Instead of Synchronize
you can also use Queue
in above method.
What is important to keep in mind is that you should not keep any other references to the control you are releasing or you may hit the trouble down the road.
Leave a comment