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
Procedure TfrmSettings.cmdGetPathClick(SEnder: TObject);
//This works for browsing for folder and inserting it in text field
//Text field can be coloured if necessary
Var
ctrlName:String;
myEdit:TEdit;
Begin
//Which control has focus
ctrlName:=ActiveControl.name;
// var
// myEdit: TEdit;
//...
myEdit := TEdit(frmSettings.FindComponent(ctrlName));
// SelectDirectoryDialog1 is on Dialogs tab
// Can browse all file systen if Finder preferences
// include the host computer in SideBar Locations
if SelectDirectoryDialog1.Execute then
Begin
myEdit.Text:=SelectDirectoryDialog1.Filename;
myEdit.Font.color:=clDefault;
self.cmdSaveSettings.Enabled:=True;
End
else
Begin
Self.cmdGetPath.Enabled:=False;
End;
//Disabled control cannot recieve focus
If Self.cmdSaveSettings.Enabled = True Then Self.cmdSaveSettings.setfocus;
End;
but this fails
procedure TForm1.Button1Click(Sender: TObject);
begin
if SelectDirectoryDialog1.Execute then
begin
Label1.Caption := SelectDirectoryDialog1.FileName;
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.