IStorageProvider.OpenFilePickerAsync does not return
See original GitHub issueDescribe the bug In some cases the file picker dialog never returns from the IStorageProvider.OpenFilePickerAsync method on Linux using the DBus file picker.
To Reproduce Open a file picker with an extension starting with a numeric value:
var storageProvider = TopLevel.GetTopLevel(_visual)!.StorageProvider;
var myFile = new FilePickerFileType("My file starting with a numeric extension");
myFile.Patterns = new []{"*.123file"};
var startingLocation = (await storageProvider.TryGetWellKnownFolderAsync(WellKnownFolder.Downloads))
?? (await storageProvider.TryGetWellKnownFolderAsync(WellKnownFolder.Documents));
var selection = await storageProvider.OpenFilePickerAsync(new FilePickerOpenOptions
{
AllowMultiple = false,
FileTypeFilter = new[] { myFile },
Title = "Please select a file to open",
SuggestedStartLocation = startingLocation
});
var file = selection.SingleOrDefault();
Run and select a file matching your filter.
The last line var file = selection.SingleOrDefault();
will never be reached and no exceptions are thrown. The call to OpenFilePickerAsync
just never returns.
When cancelling or selecting a file using either a filter not starting with a number extension or just no filter at all, then the method returns.
Expected behavior Either return a value, null or throw an exception but the method should not block when the file picker closes. Ideally one would expect the file picker to work and return the selected file info, even if the filter’s extension starts with a number.
Desktop (please complete the following information):
- OS: Linux
- Distribution: OpenSUSE Tumbleweed 20230515
- Graphics Platform: X11
- Desktop Environment: KDE Plasma 5.27.5
- Kernel: 6.3.1-2-default (64-bit)
- Version 11.0.0-preview-8
Issue Analytics
- State:
- Created 4 months ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
@dirkackerman https://github.com/AvaloniaUI/Avalonia/pull/11526 PR should fix this issue, or at least throw a proper error.
Tested on RC1.1 and it does not throw an error, its actually fixed the issue. My KDE dialog is now accepting the file extension starting with a numeric value. (I did update my OS in the mean time, don’t know if that helped).
Thanks a lot!