Skip to content

[V3] Windows: fix(application): handle error and type assertion in save file dialog #4284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: v3-alpha
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions v3/internal/go-common-file-dialog/cfd/vtblCommonFunc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ package cfd

import (
"fmt"
"github.com/go-ole/go-ole"
"strings"
"syscall"
"unsafe"

"github.com/go-ole/go-ole"
)

func hresultToError(hr uintptr) error {
Expand Down Expand Up @@ -168,7 +169,7 @@ func (vtbl *iFileDialogVtbl) getResultString(objPtr unsafe.Pointer) (string, err
return "", err
}
if shellItem == nil {
return "", fmt.Errorf("shellItem is nil")
return "", ErrorCancelled
}
defer shellItem.vtbl.release(unsafe.Pointer(shellItem))
return shellItem.vtbl.getDisplayName(unsafe.Pointer(shellItem))
Expand Down
9 changes: 8 additions & 1 deletion v3/pkg/application/dialogs_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,16 @@ func (m *windowSaveFileDialog) show() (chan string, error) {
func() (cfd.Dialog, error) {
return cfd.NewSaveFileDialog(config)
}, false)
if err != nil {
close(files)
return files, err
}
go func() {
defer handlePanic()
files <- result.(string)
f, ok := result.(string)
if ok {
files <- f
}
close(files)
}()
return files, err
Expand Down
1 change: 1 addition & 0 deletions website/src/pages/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- Fixed locking issue on Windows when multiselect dialog returns an error. Fixed in [PR](https://github.com/wailsapp/wails/pull/4156) by @johannes-luebke
- Fixed panic when closing or cancelling a `SaveFileDialog` on windows. Fixed in [PR](https://github.com/wailsapp/wails/pull/4284)

## v2.9.1 - 2024-06-18

Expand Down
Loading