File filters have extra ; and missing \0 (windows) (#113)

Co-authored-by: Nuno Cruces <ncruces@users.noreply.github.com>
This commit is contained in:
hfmrow 2024-08-14 02:53:37 +02:00 committed by GitHub
parent ee06172a03
commit 848f6d01d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -282,7 +282,7 @@ func fileOpenDialog(opts options, multi bool) (string, []string, bool, error) {
} }
var lst []string var lst []string
for i := uint32(0); i < count && err == nil; i++ { for i := uint32(0); i < count; i++ {
str, err := shellItemPath(items.GetItemAt(i)) str, err := shellItemPath(items.GetItemAt(i))
if err != nil { if err != nil {
return "", nil, true, err return "", nil, true, err
@ -499,7 +499,7 @@ func initFilters(filters FileFilters) *uint16 {
res = append(res, syscall.StringToUTF16(p)...) res = append(res, syscall.StringToUTF16(p)...)
res[len(res)-1] = ';' res[len(res)-1] = ';'
} }
res = append(res, 0) res[len(res)-1] = 0
} }
if res != nil { if res != nil {
res = append(res, 0) res = append(res, 0)
@ -521,6 +521,7 @@ func initFileTypes(filters FileFilters) (int, *win.COMDLG_FILTERSPEC) {
spec = append(spec, syscall.StringToUTF16(p)...) spec = append(spec, syscall.StringToUTF16(p)...)
spec[len(spec)-1] = ';' spec[len(spec)-1] = ';'
} }
spec[len(spec)-1] = 0
res = append(res, win.COMDLG_FILTERSPEC{ res = append(res, win.COMDLG_FILTERSPEC{
Name: syscall.StringToUTF16Ptr(f.Name), Name: syscall.StringToUTF16Ptr(f.Name),
Spec: &spec[0], Spec: &spec[0],