mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
fix windows file dialog panic when directory doesnt exist (#3582)
This commit is contained in:
parent
749c433ca6
commit
5fcebd0274
1 changed files with 12 additions and 0 deletions
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
package cfd
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
type FileFilter struct {
|
||||
// The display name of the filter (That is shown to the user)
|
||||
DisplayName string
|
||||
|
|
@ -67,6 +71,10 @@ func (config *DialogConfig) apply(dialog Dialog) (err error) {
|
|||
}
|
||||
|
||||
if config.Folder != "" {
|
||||
_, err = os.Stat(config.Folder)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = dialog.SetFolder(config.Folder)
|
||||
if err != nil {
|
||||
return
|
||||
|
|
@ -74,6 +82,10 @@ func (config *DialogConfig) apply(dialog Dialog) (err error) {
|
|||
}
|
||||
|
||||
if config.DefaultFolder != "" {
|
||||
_, err = os.Stat(config.DefaultFolder)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = dialog.SetDefaultFolder(config.DefaultFolder)
|
||||
if err != nil {
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue