View Issue Details

IDProjectCategoryView StatusLast Update
0037925LazarusWidgetsetpublic2020-10-14 18:45
ReporterChris Rorden Assigned ToDmitry Boyarintsev  
PrioritynormalSeverityminorReproducibilityalways
Status acknowledgedResolutionopen 
PlatformMacBookOSDarwin 
Product Version2.1 (SVN) 
Summary0037925: Cocoa: TSaveDialog ofOverwritePrompt issues
DescriptionThe TSaveDialog does not implement ofOverwritePrompt properly.
 1. The TSaveDialog ALWAYS generates an Overwrite Prompt, regardless of the setting of ofOverwritePrompt.
 2. An Overwrite Prompt will be generated for "unit1.pas" but not when selecting "unit1" with ".pas" in the filter, even though both functions return precisely the same filename, e.g. "unit1.pas" that will overwrite a file.
 3. TSaveDialog.Filter does not correctly set file extensions with two dots, e.g. TSaveDialog.Filter := 'Compressed Archive (.tar.gz)|*.tar.gz' will return 'filename.gz' not 'filename.tar.gz'. This impacts any format with double extensions, e.g. NII.GZ, TAR.GZ, TAR.BR, TAR.BZ, TAR.LPAQ, TAR.XZ, TAR.ZST

Steps To Reproducefunction TForm1.NiftiSaveDialogFilename(isOverwritePrompt: boolean): string;
const
     kOutFilter = 'Pascal (.pas)|*.pas|Compressed NIfTI (.nii.gz)|*.nii.gz|Volume of interest (.voi)|*.voi|Blender Volume (.bvox)|*.bvox|OSPRay Volume (.osp)|*.osp|TIF (.tif)|*.tif|NRRD (.nrrd)|*.nrrd|Compressed NRRD (.nhdr)|*.nhdr';
     kMaxExt = 8;
     kExt : array [1..kMaxExt] of string = ('*.pas', '*.nii.gz', '*.voi', '*.bvox', '*.osp', '*.tif', '*.nrrd', '*.nhdr');
var
   dlg : TSaveDialog;
begin
  result := '';
  dlg := TSaveDialog.Create(self);
  if isOverwritePrompt then
       dlg.Options := [ofEnableSizing, ofViewDetail, ofOverwritePrompt]
  else
        dlg.Options := [ofEnableSizing, ofViewDetail]; //NO disable ofOverwritePrompt
  dlg.Title := 'Save NIfTI volume';
  dlg.FileName:= 'unit1';
  dlg.Filter := kOutFilter;
  dlg.DefaultExt := kExt[1];
  dlg.FilterIndex:= 1;
  if dlg.Execute then
     result := dlg.FileName;
  dlg.Free;
end;
TagsNo tags attached.
Fixed in Revision
LazTarget-
WidgetsetCocoa
Attached Files

Activities

Chris Rorden

2020-10-14 14:30

reporter  

saveDialog.zip (110,943 bytes)

CudaText man

2020-10-14 17:24

reporter   ~0126298

Good finding. Other options of SaveDialog are ok?
-AllowMultiSelect
-CreatePrompt
-FileMustExist
-PathMustExist

jamie philbrook

2020-10-14 18:00

reporter   ~0126300

The number 3 problem is most likely in the LCL code and effects all I would guess.

the code for getting the file extension most likely needs to be rewritten to capture the compile file name without the path attached and then use POS For the first "." and take the rest of the string for the extension there afterwards.
 
 I believe windows supports multiple dot addresses in file names.. maybe it should be looked at ?

Dmitry Boyarintsev

2020-10-14 18:43

developer   ~0126302

Last edited: 2020-10-14 18:45

View 2 revisions

unlike Carbon, Cocoa doesn't provide flag similar to ofOverwritePrompt
in macOS 10.14- , there was a hackish way to emulate the flag, but with macOS 10.15 and a new security restriction in place the approach no longer works

Dmitry Boyarintsev

2020-10-14 18:44

developer   ~0126303

https://wiki.freepascal.org/Cocoa_Internals/Dialogs#File_Dialog_Options

Issue History

Date Modified Username Field Change
2020-10-14 14:30 Chris Rorden New Issue
2020-10-14 14:30 Chris Rorden File Added: saveDialog.zip
2020-10-14 17:24 CudaText man Note Added: 0126298
2020-10-14 18:00 jamie philbrook Note Added: 0126300
2020-10-14 18:43 Dmitry Boyarintsev Assigned To => Dmitry Boyarintsev
2020-10-14 18:43 Dmitry Boyarintsev Status new => acknowledged
2020-10-14 18:43 Dmitry Boyarintsev LazTarget => -
2020-10-14 18:43 Dmitry Boyarintsev Note Added: 0126302
2020-10-14 18:44 Dmitry Boyarintsev Note Added: 0126303
2020-10-14 18:45 Dmitry Boyarintsev Note Edited: 0126302 View Revisions