View Issue Details

IDProjectCategoryView StatusLast Update
0032069LazarusLCLpublic2018-01-07 04:19
ReporterChris Rorden Assigned ToDmitry Boyarintsev  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
PlatformMacBook RetinaOSDarwin 
Product Version1.9 (SVN) 
Summary0032069: File filters should handle double extensions
DescriptionTo maintain Delphi compatibility, the LCL should respect double extensions when provided as a filter by the user. Common examples of these files are tar files (.TAR.GZ / .TAR.BZ / .TAR.XZ), and ones specific to my field (neuroimaging) includes (.NII.GZ). If a user provides a filter of ".tar.gz' they are explicitly requesting something different from ".gz".

The additional information provides a patch to replicate Delphi behavior. Typical, single extensions are unchanged, but double extensions are now handled correctly.
Steps To Reproduceprocedure TForm1.Button1Click(Sender: TObject);
begin
  SaveDialog1.Filter := 'gz|*.gz|nii.gz|*.nii.gz|nii|*.nii|roi|*.roi';
  SaveDialog1.Filename := 'SaveName';
  SaveDialog1.FilterIndex:= 2;
  SaveDialog1.DefaultExt := '.roi';
  if not SaveDialog1.Execute then exit;
  Caption := SaveDialog1.Filename;
end;
Additional InformationChriss-MacBook-Pro:include rorden$ diff filedialog.inc filedialogOld.inc
306,310c306
< //Filter := ExtractFileExt(Filter);
< if (Pos('.',Filter) > 1) then //e.g. "*.nii.gz"
< Delete(Filter, 1, Pos('.',Filter)-1)
< else
< Filter := ExtractFileExt(Filter);
---
> Filter := ExtractFileExt(Filter);
TagsNo tags attached.
Fixed in Revision56997
LazTarget-
WidgetsetCocoa
Attached Files

Relationships

related to 0032895 closedDmitry Boyarintsev Cocoa: TOpenDialog crashes if filter is empty 
related to 0028687 closedFelipe Monteiro de Carvalho Cocoa Feature Request: SaveDialog Filter 

Activities

Juha Manninen

2017-10-09 15:09

developer   ~0103282

Last edited: 2017-10-09 17:16

View 2 revisions

Please create a proper patch.
 http://wiki.freepascal.org/Creating_A_Patch

Chris Rorden

2018-01-04 15:34

reporter  

multiext.patch (632 bytes)   
Index: lcl/include/filedialog.inc
===================================================================
--- lcl/include/filedialog.inc	(revision 56951)
+++ lcl/include/filedialog.inc	(working copy)
@@ -308,7 +308,10 @@
   //debugln('Filter now = ',filter);
 
   //Get the associated extension
-  Filter := ExtractFileExt(Filter);
+  if (Pos('.',Filter) > 1) then //e.g. "*.nii.gz"
+	Delete(Filter, 1, Pos('.',Filter)-1)
+  else
+  	Filter := ExtractFileExt(Filter);
   //debugln('Filter now = ',filter);
   //if an extension at this point contains a wildcard, reject it
   if (Pos('?',Filter) > 0) or (Pos('*',Filter) > 0) then exit;
multiext.patch (632 bytes)   

Dmitry Boyarintsev

2018-01-07 01:57

developer   ~0105421

please test and close if ok

Chris Rorden

2018-01-07 02:53

reporter   ~0105422

Tested - its fixed. Thanks.

Issue History

Date Modified Username Field Change
2017-06-27 16:50 Chris Rorden New Issue
2017-10-09 15:09 Juha Manninen Note Added: 0103282
2017-10-09 17:16 Juha Manninen Note Edited: 0103282 View Revisions
2017-12-28 15:44 Dmitry Boyarintsev Assigned To => Dmitry Boyarintsev
2017-12-28 15:44 Dmitry Boyarintsev Status new => assigned
2017-12-28 15:44 Dmitry Boyarintsev Relationship added related to 0032895
2018-01-04 15:34 Chris Rorden File Added: multiext.patch
2018-01-07 01:32 Dmitry Boyarintsev Relationship added related to 0028687
2018-01-07 01:57 Dmitry Boyarintsev Fixed in Revision => 56997
2018-01-07 01:57 Dmitry Boyarintsev LazTarget => -
2018-01-07 01:57 Dmitry Boyarintsev Note Added: 0105421
2018-01-07 01:57 Dmitry Boyarintsev Status assigned => resolved
2018-01-07 01:57 Dmitry Boyarintsev Resolution open => fixed
2018-01-07 02:53 Chris Rorden Note Added: 0105422
2018-01-07 04:19 Dmitry Boyarintsev Status resolved => closed