View Issue Details

IDProjectCategoryView StatusLast Update
0031133LazarusLCLpublic2016-12-17 18:01
ReporterM.AUDIOAssigned ToBart Broersma 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version1.7 (SVN)Product Buildr53670 
Target Version1.6.4Fixed in Version1.6.4 
Summary0031133: TOpenDialog Files.Count and ofAllowMultiSelect
DescriptionIn windows it reports the correct Files.Count regardless of CheckBox1.State;
In linux it does not update Files.Count and always reports the last value reported when CheckBox1 was checked. or 0 if it was never checked before.

CheckBox1.State = cbChecked is OpenDialog.Options + ofAllowMultiSelect
Steps To ReproduceTry with attached sample project.
Additional Informationwindows 7 64bit
Lazarus trunk 53633
FPC trunk 35106

Fedora 22, Ubuntu 15.04
Lazarus trunk 53670
FPC trunk 35125
TagsNo tags attached.
Fixed in Revisionr53705
LazTarget1.6.4
WidgetsetGTK 2
Attached Files
  • topendialogfilescountlinx.zip (2,236 bytes)
  • file_c.diff (1,079 bytes)
    Index: lcl/interfaces/gtk2/gtk2wsdialogs.pp
    ===================================================================
    --- lcl/interfaces/gtk2/gtk2wsdialogs.pp	(revision 53703)
    +++ lcl/interfaces/gtk2/gtk2wsdialogs.pp	(working copy)
    @@ -202,6 +202,10 @@
       //DebugLn(['Gtk2FileChooserResponseCB ']);
       theDialog := TFileDialog(data);
     
    +  theDialog.FileName := '';
    +  Files := TStringList(theDialog.Files);
    +  Files.Clear;
    +
       if arg1 = GTK_RESPONSE_CANCEL then
       begin
         TheDialog.UserChoice := mrCancel;
    @@ -212,9 +216,6 @@
       begin
         if ofAllowMultiSelect in TOpenDialog(theDialog).Options then
         begin
    -      TheDialog.FileName := '';
    -      Files := TStringList(TheDialog.Files);
    -      Files.Clear;
           cFilenames := gtk_file_chooser_get_filenames(widget);
           if Assigned(cFilenames) then
           begin
    @@ -246,6 +247,9 @@
         else
           TheDialog.FileName := cFilename;
         g_free(cFilename);
    +
    +    if not (ofAllowMultiSelect in TOpenDialog(theDialog).Options) then
    +      Files.Add(theDialog.Filename);
       end;
     
       //?? StoreCommonDialogSetup(theDialog);
    
    file_c.diff (1,079 bytes)

Activities

M.AUDIO

2016-12-17 15:31

reporter  

topendialogfilescountlinx.zip (2,236 bytes)

Alexey Tor.

2016-12-17 17:11

reporter  

file_c.diff (1,079 bytes)
Index: lcl/interfaces/gtk2/gtk2wsdialogs.pp
===================================================================
--- lcl/interfaces/gtk2/gtk2wsdialogs.pp	(revision 53703)
+++ lcl/interfaces/gtk2/gtk2wsdialogs.pp	(working copy)
@@ -202,6 +202,10 @@
   //DebugLn(['Gtk2FileChooserResponseCB ']);
   theDialog := TFileDialog(data);
 
+  theDialog.FileName := '';
+  Files := TStringList(theDialog.Files);
+  Files.Clear;
+
   if arg1 = GTK_RESPONSE_CANCEL then
   begin
     TheDialog.UserChoice := mrCancel;
@@ -212,9 +216,6 @@
   begin
     if ofAllowMultiSelect in TOpenDialog(theDialog).Options then
     begin
-      TheDialog.FileName := '';
-      Files := TStringList(TheDialog.Files);
-      Files.Clear;
       cFilenames := gtk_file_chooser_get_filenames(widget);
       if Assigned(cFilenames) then
       begin
@@ -246,6 +247,9 @@
     else
       TheDialog.FileName := cFilename;
     g_free(cFilename);
+
+    if not (ofAllowMultiSelect in TOpenDialog(theDialog).Options) then
+      Files.Add(theDialog.Filename);
   end;
 
   //?? StoreCommonDialogSetup(theDialog);
file_c.diff (1,079 bytes)

Alexey Tor.

2016-12-17 17:12

reporter   ~0096846

Added the [possible] fix, which sets Files also with non-multi-select option in dialog.

Bart Broersma

2016-12-17 17:15

developer   ~0096847

Files will hold the last files selected with ofAllowMultiSelect set.

Bart Broersma

2016-12-17 17:51

developer   ~0096849

Please test and close if OK.

Bart Broersma

2016-12-17 18:01

developer   ~0096850

@Alexey: you beat me by half an hour (but forgot about GTK3) ;-)

Issue History

Date Modified Username Field Change
2016-12-17 15:31 M.AUDIO New Issue
2016-12-17 15:31 M.AUDIO File Added: topendialogfilescountlinx.zip
2016-12-17 17:11 Alexey Tor. File Added: file_c.diff
2016-12-17 17:12 Alexey Tor. Note Added: 0096846
2016-12-17 17:15 Bart Broersma LazTarget => -
2016-12-17 17:15 Bart Broersma Note Added: 0096847
2016-12-17 17:15 Bart Broersma Status new => confirmed
2016-12-17 17:51 Bart Broersma Fixed in Revision => r53705
2016-12-17 17:51 Bart Broersma LazTarget - => 1.6.4
2016-12-17 17:51 Bart Broersma Note Added: 0096849
2016-12-17 17:51 Bart Broersma Status confirmed => resolved
2016-12-17 17:51 Bart Broersma Fixed in Version => 1.6.4
2016-12-17 17:51 Bart Broersma Resolution open => fixed
2016-12-17 17:51 Bart Broersma Assigned To => Bart Broersma
2016-12-17 17:51 Bart Broersma Target Version => 1.6.4
2016-12-17 18:01 Bart Broersma Note Added: 0096850