I found a bug in delphi Rio 10.3, an object is automatically destroyed at the end of formcreate on Android. Not in Windows.


I found a bug in delphi Rio 10.3, an object is automatically destroyed at the end of formcreate on Android. Not in Windows.
Should have something to do with refcount?

Can anybody help me?, I'm in a hurry to finish my project.

Please find code below, which is in a Blank Multi-Device application.

----------------- See code below ---------

unit Unit1;

interface

uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs;

type

TMapLayer = class(TObject)
private
fName : string;
fNumb : integer;
public
constructor Create();
destructor Destroy(); override;
end;

TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.fmx}

constructor TMapLayer.Create();
begin
inherited Create();
fName := '';
fNumb := -1;
end;

destructor TMapLayer.Destroy();
begin
inherited Destroy();
end;

procedure TForm1.FormCreate(Sender: TObject);
var layer : TMapLayer;
begin
layer := TMapLayer.Create();
// layer object is destroyed here in android (which should not happen without my calling layer.Free();
You can check by placing a breakpoint in TMapLayer.Destroy();

end;

end.

Comments

  1. Ugochukwu Mmaduekwe for Linux only

    ReplyDelete
  2. Paul TOTH just figured that out. Thanks.

    ReplyDelete
  3. Dalija, „I would say, that you need to generally update your memory management skills - ARC or no ARC :)“.

    Indeed. Well said. It is wrong on either kind of platform. The difference is the effect it has.

    ReplyDelete

Post a Comment