Recent

Author Topic: [SOLVED] opendialog does not select all files  (Read 1638 times)

apeoperaio

  • Full Member
  • ***
  • Posts: 211
[SOLVED] opendialog does not select all files
« on: January 22, 2021, 02:30:04 pm »
I encountered an issue with opendialog on mac cocoa (both on fixes and trunk branch).

If I have a folder including thousands of files, having an opendialog allowing multiple selection.
I try to load all files (selecting the first one and scrolling till the last one).
All files seems to be selected but the value of OpenDialog1.Files.Count is only few hundreds.

Is it a bug or am I missing something?

I attached a sample project and a python file to create the files.

Thank you.

Lazarus 2.1.0 r64415 FPC 3.2.0 x86_64-darwin-cocoa
« Last Edit: February 05, 2021, 09:11:51 am by apeoperaio »

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1441
  • Former Delphi 1-7, 10.2 user
Re: opendialog does not select all files
« Reply #1 on: January 22, 2021, 11:14:17 pm »
I would imagine that the behaviour is related to this.
Lazarus 2.1 r65061 FPC 3.3.1 r49223 macOS 10.14.6 Xcode 11.3.1
Lazarus 2.1 r65070 FPC 3.3.1 r49223 macOS 11.2.3 aarch64 Xcode 12.4
Lazarus 2.1 r61574 FPC 3.3.1 r42318 FreeBSD 12.1 amd64 VMware VM
Lazarus 2.1 r61574 FPC 3.0.4 Ubuntu 20.04 Parallels VM
Lazarus 2.0.10 FPC 3.2.0 Win10 Parallels VM

apeoperaio

  • Full Member
  • ***
  • Posts: 211
Re: opendialog does not select all files
« Reply #2 on: January 23, 2021, 10:03:43 am »
Thank you for your reply but not, it does not seem to be related.
I am not trying to open the files I just try to select all of them. The opendialog seems not to select all the files but only few of them.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2587
    • havefunsoft.com
Re: opendialog does not select all files
« Reply #3 on: January 24, 2021, 09:46:37 pm »
If I have a folder including thousands of files, having an opendialog allowing multiple selection.
I try to load all files (selecting the first one and scrolling till the last one).
All files seems to be selected but the value of OpenDialog1.Files.Count is only few hundreds.

Is it a bug or am I missing something?
Here's what you can do.
After you you select the first one and scroll till the last one (I presume this is followed by "Shift-Click" to select the entire list)
pay your attention to the number of files selected that is reported by the Dialog itself.

I did a test trying to select 2000 files. To my surprise, the scroll to the bottom and "shift-click"-ing results in only half of the files selected.
If done faster, even less files will be available for the selection.

The number shown on the dialog matches the number of the files reported in the code.

The slowness appears to be related to LCL's file type filtering. (I.e. an open file dialog in TextEdit doesn't have such "lag" in selecting files. Instead all files are selected when doing the same "scroll-to-bottom selection")
« Last Edit: January 24, 2021, 09:50:55 pm by skalogryz »
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2587
    • havefunsoft.com
Re: opendialog does not select all files
« Reply #4 on: January 24, 2021, 10:16:06 pm »
ok. I did add an optimization into trunk (r64419)
This should resolve the problem for THIS particular case.
and by "This case" I mean - the open dialog doesn't have ANY filter assigned. (so any file can be selected).

If you try to assign a filter (even "any file *.*" filter), you should start experiencing the same issue again.
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

apeoperaio

  • Full Member
  • ***
  • Posts: 211
Re: opendialog does not select all files
« Reply #5 on: January 25, 2021, 10:34:51 am »
Dear @skalogryz thank you.
I tested on trunk and the problem is solved if I don't use filters.
In my real application this issue remains since I use the Filter property of the opendialog.

Should I open a bug report?

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2587
    • havefunsoft.com
Re: opendialog does not select all files
« Reply #6 on: January 25, 2021, 08:49:06 pm »
Should I open a bug report?
yes. feel free to bug report the issue.

It's possible to use macOS effective method of filtering files. (just let macOS filter files by "type"... however "type" is a broader interpretation, than just "file extension"). From LCL perspective it might be a wrong behavior.
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

apeoperaio

  • Full Member
  • ***
  • Posts: 211
Re: opendialog does not select all files
« Reply #7 on: January 26, 2021, 09:18:00 am »
Reported as ID 0038399
https://bugs.freepascal.org/view.php?id=38399

Thank you so much for all your work on macOS.

apeoperaio

  • Full Member
  • ***
  • Posts: 211
Re: opendialog does not select all files
« Reply #8 on: February 01, 2021, 12:32:33 pm »
Thanks skalogryz!
Tested on trunk and it works adding CocoaUseUTIFilter:= True as specified in:
https://wiki.freepascal.org/Cocoa_Internals/Dialogs#File_Type_Filters

Will be the
CocoaUseUTIFilter = True
the default?


skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2587
    • havefunsoft.com
Re: opendialog does not select all files
« Reply #9 on: February 01, 2021, 03:31:29 pm »
Will be the
CocoaUseUTIFilter = True
the default?
No.
Cocoa "native" behavior (UTI) is not LCL compatible.
I'd anticipate CocoaUseUTIFilter to remain "false" by default in future.
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

apeoperaio

  • Full Member
  • ***
  • Posts: 211
[SOLVED] Re: opendialog does not select all files
« Reply #10 on: February 05, 2021, 09:11:32 am »
Solved on trunk, see https://bugs.freepascal.org/view.php?id=38399
Thanks skalogryz!

 

TinyPortal © 2005-2018