Skip to content

Commit 105c10a

Browse files
fix: don't return error when SaveFileDialog is cancelled by the user
1 parent d1838f4 commit 105c10a

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

v2/internal/go-common-file-dialog/cfd/errors.go

+2
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ import "errors"
44

55
var (
66
ErrCancelled = errors.New("cancelled by user")
7+
ErrInvalidGUID = errors.New("guid cannot be nil")
8+
ErrEmptyFilters = errors.New("must specify at least one filter")
79
)

v2/internal/go-common-file-dialog/cfd/iShellItemArray.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (vtbl *iShellItemArrayVtbl) getItemAt(objPtr unsafe.Pointer, index uintptr)
5858
return "", err
5959
}
6060
if shellItem == nil {
61-
return "", fmt.Errorf("shellItem is nil")
61+
return "", ErrCancelled
6262
}
6363
defer shellItem.vtbl.release(unsafe.Pointer(shellItem))
6464
return shellItem.vtbl.getDisplayName(unsafe.Pointer(shellItem))

v2/internal/go-common-file-dialog/cfd/vtblCommonFunc.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (vtbl *iModalWindowVtbl) show(objPtr unsafe.Pointer, hwnd uintptr) error {
3434
func (vtbl *iFileDialogVtbl) setFileTypes(objPtr unsafe.Pointer, filters []FileFilter) error {
3535
cFileTypes := len(filters)
3636
if cFileTypes < 0 {
37-
return fmt.Errorf("must specify at least one filter")
37+
return ErrEmptyFilters
3838
}
3939
comDlgFilterSpecs := make([]comDlgFilterSpec, cFileTypes)
4040
for i := 0; i < cFileTypes; i++ {
@@ -168,7 +168,7 @@ func (vtbl *iFileDialogVtbl) getResultString(objPtr unsafe.Pointer) (string, err
168168
return "", err
169169
}
170170
if shellItem == nil {
171-
return "", fmt.Errorf("shellItem is nil")
171+
return "", ErrCancelled
172172
}
173173
defer shellItem.vtbl.release(unsafe.Pointer(shellItem))
174174
return shellItem.vtbl.getDisplayName(unsafe.Pointer(shellItem))
@@ -177,7 +177,7 @@ func (vtbl *iFileDialogVtbl) getResultString(objPtr unsafe.Pointer) (string, err
177177
func (vtbl *iFileDialogVtbl) setClientGuid(objPtr unsafe.Pointer, guid *ole.GUID) error {
178178
// Ensure the GUID is not nil
179179
if guid == nil {
180-
return fmt.Errorf("guid cannot be nil")
180+
return ErrInvalidGUID
181181
}
182182

183183
// Call the SetClientGuid method

website/src/pages/changelog.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616

1717
### Fixed
1818
- Fixed Window size issues on Wayland [PR](https://github.com/wailsapp/wails/pull/4047) by [@lyimmi](https://github.com/lyimmi)
19+
- Fixed SaveFileDialog cancellation result [PR](https://github.com/wailsapp/wails/pull/4253) by [@FrancescoLuzzi](https://github.com/FrancescoLuzzi)
1920

2021

2122
### Changed
@@ -88,10 +89,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8889
- Fixed CGO memory issue on Darwin by @leaanthony in [PR](https://github.com/wailsapp/wails/pull/3590)
8990
- Fixed an error that occurred when an author name contains a string that is not suitable for JSON. Fixed by @taiseiotsuka in [PR](https://github.com/wailsapp/wails/pull/3638)
9091
- Fixed MacOS build to use `outputfilename` from wails.json. [#3200](https://github.com/wailsapp/wails/issues/3200)
91-
- Fixed file drop events on windows. Fixed in [PR](https://github.com/wailsapp/wails/pull/3595) by @FrancescoLuzzi
9292
- Fixed doctor command not finding pkg-config on Solus. [PR #3670](https://github.com/wailsapp/wails/pull/3670) by [@ianmjones](https://github.com/ianmjones)
9393
- Fixed binding for struct fields that were exported but had no json tags. [PR #3678](https://github.com/wailsapp/wails/pull/3678)
94-
- Fixed file drop events on Windows in [PR](https://github.com/wailsapp/wails/pull/3595) by @FrancescoLuzzi
94+
- Fixed file drop events on Windows in [PR](https://github.com/wailsapp/wails/pull/3595) by [@FrancescoLuzzi](https://github.com/FrancescoLuzzi)
9595
- Modified `ZoomFactor` and `IsZoomControlEnabled` options to be Windows-only options in PR[#3644](https://github.com/wailsapp/wails/pull/3644) by @levinit
9696
- Added nil check for Drag-n-Drop on Windows. Fixed by in [PR](https://github.com/wailsapp/wails/pull/3597) by @leaanthony based on the suggestion by @Alpa-1 in [#3596](https://github.com/wailsapp/wails/issues/3596).
9797
- Fixed typos in various .mdx files. [PR #3628](https://github.com/wailsapp/wails/pull/3628) by [@deining](https://github.com/deining)

0 commit comments

Comments
 (0)