IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Composants FMX Delphi Discussion :

[FMX-Android] Segfault 11


Sujet :

Composants FMX Delphi

  1. #1
    Membre éprouvé
    Avatar de Aooka
    Homme Profil pro
    Scripting Powershell & Wlangage
    Inscrit en
    Juillet 2015
    Messages
    227
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 28
    Localisation : France, Haute Savoie (Rhône Alpes)

    Informations professionnelles :
    Activité : Scripting Powershell & Wlangage

    Informations forums :
    Inscription : Juillet 2015
    Messages : 227
    Points : 1 095
    Points
    1 095
    Par défaut [FMX-Android] Segfault 11
    Bonjour à tous,

    Je rencontre depuis hier un Segmentation Fault (11) lors de la compilation sur mon appareil Android. Or lorsque je lance mon programme sous Win32 tout marche à marveille. Je n'arrive pas à trouver la ligne où sa plante, j'ai regarder toute mes boucles, je ne trouve pas. Donc je viens demander un petit coup de pouce à une main experte

    Je vous laisse donc mon code ci dessous :
    Unit Main :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    unit uMain;
     
    interface
     
    uses
    {$IF DEFINED(ANDROID)}
      Androidapi.JNI.JavaTypes, FMX.Helpers.Android,
      Androidapi.JNI.GraphicsContentViewText,
      Androidapi.JNIBridge, Androidapi.Helpers,
    {$ENDIF}
      System.SysUtils, System.Types, System.UITypes, System.Classes,
      System.Variants,
      FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls,
      FMX.Controls.Presentation, FMX.Edit, FMX.Objects,
      Generics.Collections,
     
      DatabaseHelper, Data.sqlexpr, Data.DbxSqlite, Data.DB, FMX.Menus, FMX.ListBox,
      FMX.Layouts,
     
      uIdentification;
     
    type
      TFormMain = class(TForm)
        ToolBar: TToolBar;
        BTN_ToDo: TButton;
        VSBMain: TVertScrollBox;
     
        procedure FormShow(Sender: TObject);
        procedure OnVSBMainResize(Sender: TObject);
        procedure FormCreate(Sender: TObject);
     
      private
        F_sNomPackageAndroid, F_sCheminBddWindows: String;
        LBLList: TList<TLabel>;
        uIdentification : TFormIdentification;
     
        procedure AffBdd;
     
      public
        procedure resultIsLogged(sValue: String);
     
    end;
     
    var
      FormMain: TFormMain;
     
    implementation
     
    {$R *.fmx}
     
    procedure TFormMain.FormCreate(Sender: TObject);
      {$IF DEFINED(ANDROID)}
      Var
        PackageManager: JPackageManager;
        PackageInfo: JPackageInfo;
      {$ENDIF}
    begin
      { Initialisation vers les dossiers des bases de données Android et Windows }
      F_sNomPackageAndroid := '';
      F_sCheminBddWindows := '.\bdd\';
      { Pour Android, on récupère le nom du package qui est utilisé par Android pour le chemin de l'application }
      {$IF DEFINED(ANDROID)}
        PackageManager := SharedActivity.getPackageManager;
        PackageInfo := PackageManager.getPackageInfo(SharedActivityContext.getPackageName(), TJPackageManager.JavaClass.GET_ACTIVITIES);
        F_sNomPackageAndroid := JStringToString(PackageInfo.packageName);
        { sImgPath := '/data/data/' + F_sNomPackageAndroid + '/files/'; }
      {$ELSE}
        { sImgPath := '../../pictures/'; }
      {$ENDIF}
      LBLList := TList<TLabel>.Create;
    end;
     
    procedure TFormMain.FormShow(Sender: TObject);
    begin
      uIdentification := TFormIdentification.Create(Self);
      uIdentification.Logged := resultIsLogged;
      {$IF DEFINED(ANDROID)}
        uIdentification.Show;
      {$ELSE}
        uIdentification.ShowModal;
      {$ENDIF}
    end;
     
    procedure TFormMain.AffBdd;
    Var
      ConnexionBdd: TDbHelper;
      SelectQuery: TSQLQuery;
      I: Integer;
      LBL: TLabel;
    Begin
      ConnexionBdd := TDbHelper.Create(F_sNomPackageAndroid, F_sCheminBddWindows, 'Test.3db');
      SelectQuery := TSQLQuery.Create(nil);
     
      I := 0;
      while I < LBLList.Count do
      Begin
        If LBLList.Items[I] <> nil then
        begin
          LBLList.Items[I].DisposeOf;
        End;
        Inc(I);
      End;
     
      With SelectQuery Do
      Begin
        SQLConnection := ConnexionBdd.GetConnection;
        Active := false;
        SQL.Text := 'SELECT Imputation1 FROM DCommand WHERE (Cle >= 20130657 AND Cle <= 20130668);';
        Open;
        First;
        I := 0;
        While Not EOF Do
        Begin
            LBL := TLabel.Create(VSBMain);
            LBL.Parent := VSBMain as TFmxObject;
            LBL.Text := SelectQuery['Imputation1'];
            LBL.Height := 30;
            LBL.StyledSettings := LBL.StyledSettings - [TStyledSetting.Size];
            LBL.Font.Size := 9;
            LBL.Position.X := (Round(VSBMain.Width / 4) - LBL.Width - (1.1 * LBL.Width));
            LBL.Position.Y := (Round(VSBMain.Height / 20) + I * LBL.Height + 20);
            LBL.Align := TAlignLayout.Top;
            LBLList.Add(LBL);
            Inc(I);
            Next;
        End;
        Close;
        DisposeOf;
      End;
      ConnexionBdd.Close;
    End;
     
    procedure TFormMain.OnVSBMainResize(Sender: TObject);
    Var
      I: Integer;
    Begin
      I := 0;
      While I < LBLList.Count Do
      begin
        If LBLList.Items[I] <> nil Then
          LBLList.Items[I].Position.X := (Round(VSBMain.Width / 4) - LBLList.Items[I].Width);
        Inc(I);
      end;
    End;
     
    procedure TFormMain.resultIsLogged(sValue: String);
    Begin
      If sValue = 'REPEAT' Then
      Begin
        uIdentification.Show;
      End
      Else if sValue = 'OK' then
      Begin
        uIdentification.Close;
        AffBdd;
      End
      Else
      Begin
        uIdentification.Close;
        Application.Terminate;
      End;
    End;
     
    end.
    Unit Identification :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    unit uIdentification;
     
    interface
     
    uses
      {$IF DEFINED(ANDROID)}
        Androidapi.JNI.JavaTypes , FMX.Helpers.Android , ANdroidapi.JNI.GraphicsContentViewText ,
        Androidapi.JNIBridge , Androidapi.Helpers ,
      {$ENDIF}
     
      System.SysUtils , System.Types , System.UITypes , System.Classes , System.Variants ,
      FMX.Types , FMX.Controls , FMX.Forms , FMX.Graphics , FMX.Dialogs , FMX.StdCtrls ,
      FMX.Controls.Presentation, FMX.Edit, FMX.Objects,
     
      DatabaseHelper , Data.sqlexpr , Data.DbxSqlite , Data.DB , FMX.Menus , FMX.ListBox ,
      FMX.Layouts;
     
    type
      TLogged = procedure(sIsLogged : String) Of Object;
     
      TFormIdentification = class(TForm)
        LBL_Login: TLabel;
        LBL_Mdp: TLabel;
        CBB_Login: TComboBox;
        BTN_Connexion: TButton;
        BTN_Annulee: TButton;
        Edit_Mdp: TEdit;
        procedure BTN_ConnexionClick(Sender: TObject);
        procedure OnFormIdentificationCreate(Sender: TObject);
        procedure OnFormIdentificationResize(Sender: TObject);
        procedure BTN_AnnuleeClick(Sender: TObject);
        procedure FormShow(Sender: TObject);
      private
        F_sNomPackageAndroid , F_sCheminBddWindows : String;
      public
        Logged : TLogged;
      end;
     
    var
      FormIdentification: TFormIdentification;
     
    implementation
     
    {$R *.fmx}
     
    procedure TFormIdentification.BTN_AnnuleeClick(Sender: TObject);
    begin
      Logged('STOP');
    end;
     
    procedure TFormIdentification.BTN_ConnexionClick(Sender: TObject);
    Var
      ConnexionBdd : TDbHelper;
      SelectQuery : TSQLQuery;
    Begin
      If CBB_Login.Selected = nil Then
        Exit;
     
      ConnexionBdd := TDbHelper.Create(F_sNomPackageAndroid , F_sCheminBddWindows , 'Test.3db');
      SelectQuery := TSQLQuery.Create(nil);
     
      With SelectQuery Do
      Begin
        SQLConnection := ConnexionBdd.GetConnection;
        Active := false;
        SQL.Text := 'SELECT login, mdp FROM users WHERE login=:pLogin;';
        ParamByName('pLogin').AsString := CBB_Login.Selected.Text;
        //ParamByName('pMdp').AsString := Edit_Mdp.Text;
        Open;
        First;
        if Not EOF Then
        Begin
          Logged('OK');
        Next;
        End
        Else
        Begin
          Logged('REPEAT');
        End;
     
        Close;
        DisposeOf;
      End;
      ConnexionBdd.Close;
    End;
     
    procedure TFormIdentification.FormShow(Sender: TObject);
    Var
      ConnexionBdd : TDbHelper;
      SelectQuery : TSQLQuery;
    Begin
      ConnexionBdd := TDbHelper.Create(F_sNomPackageAndroid , F_sCheminBddWindows , 'Test.3db');
      SelectQuery := TSQLQuery.Create(nil);
     
      With SelectQuery Do
      Begin
        SQLConnection := ConnexionBdd.GetConnection;
        Active := false;
        SQL.Text := 'SELECT login FROM users;';
     
        Open;
        First;
        While Not EOF Do
        Begin
          CBB_Login.Items.Add(SelectQuery['login']);
          Next;
        End;
        Close;
        DisposeOf;
     
      End;
      ConnexionBdd.Close;
    end;
     
    procedure TFormIdentification.OnFormIdentificationCreate(Sender: TObject);
      {$IF DEFINED(ANDROID)}
      Var
        PackageManager : JPackageManager;
        PackageInfo : JPackageInfo;
      {$ENDIF}
    Begin
      { Initialisation vers les dossiers des bases de données Android et Windows }
        F_sNomPackageAndroid := '';
        F_sCheminBddWindows := '.\bdd\';
      { Pour Android, on récupère le nom du package qui est utilisé par Android pour le chemin de l'application }
      {$IF DEFINED(ANDROID)}
        PackageManager := SharedActivity.getPackageManager;
        PackageInfo := PackageManager.getPackageInfo(SharedActivityContext.getPackageName() , TJPackageManager.JavaClass.GET_ACTIVITIES);
        F_sNomPackageAndroid := JStringToString(PackageInfo.packageName);
        { sImgPath := '/data/data/' + F_sNomPackageAndroid + '/files/'; }
      {$ELSE}
        { sImgPath := '../../pictures/'; }
      {$ENDIF}
    End;
     
    procedure TFormIdentification.OnFormIdentificationResize(Sender: TObject);
    Begin
      LBL_Login.Width := Round(Self.Width / 2.5);
      LBL_Mdp.Width := Round(Self.Width / 2.5);
      CBB_Login.Width := Round(Self.Width / 2.5);
      Edit_Mdp.Width := Round(Self.Width / 2.5);
      BTN_Connexion.Width := Round(Self.Width / 6);
      BTN_Annulee.Width := Round(Self.Width / 6);
     
      LBL_Login.Position.X := Round(((Self.Width - LBL_Login.Width) / 2) - (LBL_Login.Width / 3));
      CBB_Login.Position.X := Round(((Self.Width - CBB_Login.Width) / 2) + (CBB_Login.Width / 3));
      LBL_Mdp.Position.X := Round(((Self.Width - LBL_Mdp.Width) / 2) - (LBL_Mdp.Width / 3));
      Edit_Mdp.Position.X := Round(((Self.Width - Edit_Mdp.Width) / 2) + (Edit_Mdp.Width / 3));
      BTN_Connexion.Position.X := Round(((Self.Width - BTN_Connexion.Width) / 2) - BTN_Connexion.Width);
      BTN_Annulee.Position.X := Round(((Self.Width - BTN_Annulee.Width) / 2) + BTN_Annulee.Width);
     
      LBL_Login.Position.Y := Round((Self.Height - LBL_Login.Height) / 2) - LBL_Login.Height * 2 - 50;
      LBL_Mdp.Position.Y := Round((Self.Height - LBL_Mdp.Height) / 2) + LBL_Login.Height * 2 - 50;
      CBB_Login.Position.Y := Round((Self.Height - CBB_Login.Height) / 2) - LBL_Login.Height * 2 - 50;
      Edit_Mdp.Position.Y := Round((Self.Height - Edit_Mdp.Height) / 2) + LBL_Login.Height * 2 - 50;
      BTN_Connexion.Position.Y := Round((Self.Height - BTN_Connexion.Height) / 2) + BTN_Connexion.Height * 3;
      BTN_Annulee.Position.Y := Round((Self.Height - BTN_Annulee.Height) / 2) + BTN_Annulee.Height * 3;
    End;
     
    end.
    En gros, l'unité Main appel directement l'unité Identification via un Show, si le client s'est bien identifié alors on le redirige vers l'unité main où une table de ma bdd sera affiché via des TLabel. Rien de plus.
    Le problème c'est que le compilateur ne me dit rien de spécial, ne me précise aucune ligne particulière où regarder, donc un peu perdu .. Si quelqu'un arrive à me trouver une solution, je lui paye un bonbon !

    Allé, sur ce, bonne journée de la Hautes Savoie, en remerciant d'avance les âmes charitables !

    Bien Cordialement,

  2. #2
    Rédacteur/Modérateur

    Avatar de SergioMaster
    Homme Profil pro
    Développeur informatique retraité
    Inscrit en
    Janvier 2007
    Messages
    15 038
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 67
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Développeur informatique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Janvier 2007
    Messages : 15 038
    Points : 40 943
    Points
    40 943
    Billets dans le blog
    62
    Par défaut
    Bonjour,

    une piste sans conviction : ce ne serait pas dans l'Event onResize ? n'y aurait-il pas moyen de faire plus simple avec les Anchors et Align

    autre chose qui n'a rien à voir pourquoi un First juste après un Open ? AMHA il ne sert à rien j'ai toujours compris (mais peut être ai-je tort) que à l'ouverture on était positionné sur le 1° enregistrement.

    Idem le Next de la ligne 74 de identification me semble inutile
    MVP Embarcadero
    Delphi installés : D3,D7,D2010,XE4,XE7,D10 (Rio, Sidney), D11 (Alexandria), D12 (Athènes)
    SGBD : Firebird 2.5, 3, SQLite
    générateurs États : FastReport, Rave, QuickReport
    OS : Window Vista, Windows 10, Windows 11, Ubuntu, Androïd

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. FMX Android problème de streaming MPEG en HTTP avec Indy
    Par rdr2510 dans le forum Web & réseau
    Réponses: 0
    Dernier message: 22/08/2015, 07h33
  2. Utilisation de librairie externe '*.so' FMX Android
    Par rdr2510 dans le forum Delphi
    Réponses: 1
    Dernier message: 02/10/2014, 10h51
  3. Réponses: 0
    Dernier message: 02/10/2014, 08h41
  4. [Android] Connexion entre Entre FMX application Android et PHP CodeIgniter
    Par jeanparfait dans le forum Composants FMX
    Réponses: 1
    Dernier message: 13/03/2014, 02h59
  5. Thread FMX Android plante
    Par retwas dans le forum Composants FMX
    Réponses: 17
    Dernier message: 03/12/2013, 08h30

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo