Quantcast
Channel: Embarcadero Community - Embarcadero Community
Viewing all articles
Browse latest Browse all 1963

Dynamic controls on Android gives Segmentation fault (11)

$
0
0

I am using RAD Studio 10 Seattle and writing the code in Delphi. I’m working on a multi platform project where I have to create lots of controls dynamically as a result of some major calculations. When changing the conditions, I need to remove all dynamically created controls and make the recalculations and finally create the controls again.

I handle this by first dynamically create a TScrollBox (iOFPLayout) on top of a TTabItem. I move the predefined header TToolBar from the TTabItem to the TScrollBox by changing its parent. Then I create arrays of TLabel, TEdit and TButton controls on the TScrollBox. (I need to interact with the dynamically created controls in code) This part works fine on all platforms. When I remove the controls I use the code below.

procedure TTabbedForm.RemoveOFP();
begin
  // Move the ToolBar2 back to TabItem3 so it won’t get destroyed
  ToolBar2.Parent := TabItem3; 
  if Assigned(iOFPLayout) then
  begin
    iOFPLayout.Release;
    iOFPLayout.DisposeOf;
    iOFPLayout := nil;
    Application.ProcessMessages;
  end;
end;

On Windows x86, x64 and OS X it works fine. On Android it works fine the first time the TScrollBox is created and filled with dynamically created controls. After the TScrollBox has been removed and recreated I get an “Access Violation” or “Segmentation fault (11)” error at some random point when the dynamic arrays of TLabel controls are created on top of the TScrollBox.

 

I get a feeling that this has to do with ARC. I have read everything I can about ARC and tested every suggestion I can find but nothing seem to work. Does anyone know what’s wrong? 


Viewing all articles
Browse latest Browse all 1963

Trending Articles