mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
[V3] Windows: fix(application): handle error and type assertion in save file dialog (#4284)
* fix(application): handle error and type assertion in save file dialog --------- Co-authored-by: hkhere <hk@tinyclouds.cn> Co-authored-by: Atterpac <89053530+atterpac@users.noreply.github.com> Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
This commit is contained in:
parent
9fe9c6647e
commit
ca449a7706
3 changed files with 12 additions and 3 deletions
|
|
@ -23,6 +23,7 @@ After processing, the content will be moved to the main changelog and this file
|
|||
|
||||
## Fixed
|
||||
<!-- Bug fixes -->
|
||||
- Fixed panic when closing or cancelling a `SaveFileDialog` on windows. Fixed in [PR](https://github.com/wailsapp/wails/pull/4284) by @hkhere
|
||||
- Fixed HTML level drag and drop on Windows by [@mbaklor](https://github.com/mbaklor) in [#4259](https://github.com/wailsapp/wails/pull/4259)
|
||||
|
||||
## Deprecated
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue