Cocoa: TOpenDialog crashes if filter is empty
Original Reporter info from Mantis: crlab @neurolabusc1
-
Reporter name: Chris Rorden
Original Reporter info from Mantis: crlab @neurolabusc1
- Reporter name: Chris Rorden
Description:
Recent updates to Cocoa allow the user to specify a filter to the open dialog, for example OpenDialog.Filter := "Bitmap|.bmp", however by default the filter is empty and should show all files. With recent versions of Cocoa this results in a crash, as "lFilter" has not been assigned.
Steps to reproduce:
Add TButton and TOpenDialog to form - by default TOpenDialog has empty filter. Have button execute OpenDialog:
procedure TForm1.Button1Click(Sender: TObject);
begin
if not OpenDialog1.Execute then exit;
caption := OpenDialog1.Filename;
end;
Additional information:
This can be fixed by adding the line "lFilter := nil;" to CocoaWSDialogs.pp :
procedure CreateAccessoryView(AOpenOwner: NSOpenPanel; ASaveOwner: NSSavePanel);
const
INT_MIN_ACCESSORYVIEW_WIDTH = 300;
var
lRect: NSRect;
lText: NSTextField;
lTextStr: NSString;
lDialogView: NSView;
lAccessoryWidth: Integer = INT_MIN_ACCESSORYVIEW_WIDTH;
begin
lFilter := nil;
// check if the accessory is necessary
if FileDialog.Filter = '' then Exit;
Mantis conversion info:
- Mantis ID: 32895
- OS: Darwin
- OS Build: 10.11.6
- Build: 56863
- Platform: MacBook 13"
- Version: 1.9 (SVN)
- Fixed in revision: 56899 (#cfcf7e71)