Recent

Author Topic: SelectDirectoryDialog crashes on MacOs  (Read 196 times)

Wilko500

  • Full Member
  • ***
  • Posts: 180
SelectDirectoryDialog crashes on MacOs
« on: September 28, 2025, 06:00:57 pm »
I have a problem with Selecting a directory on MacOs (Sequoia 15.7 Xcode 26).  I have this dialogue working successfully on another program but  when I copied the procedure to a new project it fails with a "program quit unexpectedly".  To try and diagnose this I created a test project with just a single call to SelectDirectoryDialog1.Execute and that also fails.
This procedure works in its original project
Code: Pascal  [Select][+][-]
  1. Procedure TfrmSettings.cmdGetPathClick(SEnder: TObject);
  2. //This works for browsing for folder and inserting it in text field
  3. //Text field can be coloured if necessary
  4. Var
  5.   ctrlName:String;
  6.   myEdit:TEdit;
  7. Begin
  8.   //Which control has focus
  9.   ctrlName:=ActiveControl.name;
  10.   // var
  11.   //  myEdit: TEdit;
  12.   //...
  13.   myEdit := TEdit(frmSettings.FindComponent(ctrlName));
  14.   // SelectDirectoryDialog1 is on Dialogs tab
  15.   // Can browse all file systen if Finder preferences
  16.   // include the host computer in SideBar Locations
  17.    if SelectDirectoryDialog1.Execute then
  18.        Begin
  19.        myEdit.Text:=SelectDirectoryDialog1.Filename;
  20.        myEdit.Font.color:=clDefault;
  21.        self.cmdSaveSettings.Enabled:=True;
  22.        End
  23.    else
  24.        Begin
  25.        Self.cmdGetPath.Enabled:=False;
  26.    End;
  27.    //Disabled control cannot recieve focus
  28.    If Self.cmdSaveSettings.Enabled = True Then Self.cmdSaveSettings.setfocus;
  29. End;  
but this fails
Code: Pascal  [Select][+][-]
  1.    procedure TForm1.Button1Click(Sender: TObject);
  2.     begin
  3.       if SelectDirectoryDialog1.Execute then
  4.       begin
  5.         Label1.Caption := SelectDirectoryDialog1.FileName;
  6.       end;
It appears that the crash occurs within CocoaWSDialogs.  I am a loss to see why it works in one program but fails in another. Both are run in LAZ/FPC 43-323. The failure occurs in both release and debug modes. Test project attached.

MacBook Pro mid 2015 with OS Monterey 12.7.6
FPC 3.2.3 Lazarus 3.7
FPC 3.2.2 Lazarus 3.4

 

TinyPortal © 2005-2018