Class segmentation fault (11)

大城市里の小女人 提交于 2019-12-10 13:36:44

问题


Please follow the steps below:

  1. Create New Firemonkey Moblie Application
  2. Add TGeustureManager component to the Form
  3. Add 2 TButton components to the Form

    • Button1.Text: "Button1: Do something..."
    • Button2.Text: "Button2: Exit Application..."

  4. Double click on Button2 Component and write the following code for OnClick Event:

    procedure TForm1.Button2Click(Sender: TObject);
    begin
      if MessageDlg('Are you sure you want to Exit?', TMsgDlgType.mtWarning,
              [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], 0) = mrYes then
        SharedActivity.finish;
    end;
    
  5. Run the application in debug mode.
  6. on the device, click the button 2, then click yes to the popped up message. An exception will appear:

Why is this exception raised?

I thought it is related to unused TGeustureManager component. but NO it is NOT:

  1. If you open the Location Demo project that comes with Delphi xe5.
  2. Add TButton component to Location Label as shown in the image below:

  3. Add the same code as above to OnClick Event.
  4. Run the application, and click on Button5, you will get the same exception.

Is this a bug should I report? or am I doing something wrong?


回答1:


Possibly that you are killing the activity that is running, before its execution flow has been exhausted, thereby causing problems. Much like freeing a form in a form method....

What happens if you replace:

SharedActivity.finish

with:

uses
  FMX.Helpers.Android;
...
CallOnUIThread(procedure begin SharedActivity.finish end);

[ Typed from memory, so may need some tweaking ]




回答2:


if you want only to close application un can try this:

case MessageDlg('Close Application?', System.UITypes.TMsgDlgType.mtInformation,
    [
      System.UITypes.TMsgDlgBtn.mbYes,
      System.UITypes.TMsgDlgBtn.mbNo
    ], 0) of
    { Detect which button was pushed and show a different message }
    mrNo:
      showmessage('');
    mrYes:
      halt;
  end;



回答3:


I have contacted Embarcadero for this issue.

They said that it is because TApplication.Terminate is not yet implemented in FireMonkey platform for mobile.

They open a ticket to implement TApplication.Terminate in nex hot fix.

Let's hope that will not take ages.




回答4:


I have the same error on a very simple Location test app, it happens when setting text on a label. The label was set to auto size, and when I changed it to a static size the error went away.

Delphi XE6, line 681 in FMX.TextLayout.GPU

I am using a Samsung S4 phone.

procedure TForm_StayTogether.LocationSensor1LocationChanged(Sender: TObject;
  const OldLocation, NewLocation: TLocationCoord2D);
begin
  DistLabel.Text:= FloatToStr(LocationSensor1.Distance);
  AccLabel.Text:= FloatToStr(LocationSensor1.Accuracy);
  LatLabel.Text:= FloatToStr(NewLocation.Latitude);
  LonLabel.Text:= FloatToStr(NewLocation.Longitude);
end;



回答5:


I've just experienced something similar, a very tiny app with little code giving this same error (Segmentation fault 11) every single time I quit the app on the Android device (Galaxy Note 2 in my case).

For what it's worth, the problem disappeared when I went to the Stylebook I had earlier put on the form and cleared it. I think I had earlier copied that Stylebook from another test unit.

Mike



来源:https://stackoverflow.com/questions/19875029/class-segmentation-fault-11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!