godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.38k stars 21.26k forks source link

Native FileDialog shows `All Files (*) (*.*)` filter on Windows 10 #99596

Open RedMser opened 2 days ago

RedMser commented 2 days ago

Tested versions

Godot v4.4.dev5.official [9e6098432]

System information

Godot v4.4.dev5 - Windows 10.0.19044 - Multi-window, 3 monitors - OpenGL 3 (Compatibility) - NVIDIA GeForce RTX 2080 (NVIDIA; 32.0.15.5585) - Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz (12 threads)

Issue description

Image

Could not be reproduced by @bruvzg on Windows 11 and Wine, so it may be specific to Windows 10.

Steps to reproduce

Create a native FileDialog with at least one Filters entry. Then open it and check dropdown.

Minimal reproduction project (MRP)

https://github.com/user-attachments/files/17882069/auto-file-extension-native-dialogs.zip

RedMser commented 2 days ago

I couldn't find a good source on this behavior, but this blog post says:

Note that Vista automatically appends the wildcard pattern to the file type description (the pszName member of COMDLG_FILTERSPEC). This is different from earlier OSes, where it was a convention for the description to include the pattern. If you use a description that contains a pattern, Vista will try to compensate for this by looking at the end of the description. If the pattern appears at the end of the description, Vista will not add the pattern again. For example, if your strings are:

Description: All files (*.*) Pattern: *.*

Vista will not add another "(*.*)" to the description. The pattern in the description does not have to be in parentheses, however most apps do use parentheses, so that's why Vista checks for them.

So it might be that this would not render twice if the appended display string was changed to (*.*). Or we could stop appending the extension list ourself, since Windows does it automatically.

Win11 might be more lenient here, but at least in Win10 (and likely Vista/7/8) it renders like in the screenshot above.

From my research, Wine doesn't ever add the extensions to the description. Here they add to array without modification, and here they add to dropdown.