From 848f6d01d3fb9b45d61836d73d1f60d783db235b Mon Sep 17 00:00:00 2001 From: hfmrow <45952208+hfmrow@users.noreply.github.com> Date: Wed, 14 Aug 2024 02:53:37 +0200 Subject: [PATCH] File filters have extra ; and missing \0 (windows) (#113) Co-authored-by: Nuno Cruces --- file_windows.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/file_windows.go b/file_windows.go index a117009..c820247 100644 --- a/file_windows.go +++ b/file_windows.go @@ -282,7 +282,7 @@ func fileOpenDialog(opts options, multi bool) (string, []string, bool, error) { } 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)) if err != nil { return "", nil, true, err @@ -499,7 +499,7 @@ func initFilters(filters FileFilters) *uint16 { res = append(res, syscall.StringToUTF16(p)...) res[len(res)-1] = ';' } - res = append(res, 0) + res[len(res)-1] = 0 } if res != nil { res = append(res, 0) @@ -521,6 +521,7 @@ func initFileTypes(filters FileFilters) (int, *win.COMDLG_FILTERSPEC) { spec = append(spec, syscall.StringToUTF16(p)...) spec[len(spec)-1] = ';' } + spec[len(spec)-1] = 0 res = append(res, win.COMDLG_FILTERSPEC{ Name: syscall.StringToUTF16Ptr(f.Name), Spec: &spec[0],