Skip to content

Commit

Permalink
fix OpenFileDialog will locked under macos
Browse files Browse the repository at this point in the history
  • Loading branch information
hongfushi committed Sep 18, 2023
1 parent 793191a commit 9b81ea7
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions v3/pkg/application/dialogs.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package application

import (
"runtime"
"strings"
"sync"
)
Expand Down Expand Up @@ -265,7 +266,16 @@ func (d *OpenFileDialogStruct) PromptForSingleSelection() (string, error) {
if d.impl == nil {
d.impl = newOpenFileDialogImpl(d)
}
selection, err := invokeSyncWithResultAndError(d.impl.show)
var selection []string
var err error
//Fixed: macos will locked
// C.showOpenFileDialog has checked dispatch_async dispatch_get_main_queue()
if runtime.GOOS == "darwin" {
selection, err = d.impl.show()
} else {
selection, err = invokeSyncWithResultAndError(d.impl.show)
}

var result string
if len(selection) > 0 {
result = selection[0]
Expand All @@ -289,7 +299,15 @@ func (d *OpenFileDialogStruct) PromptForMultipleSelection() ([]string, error) {
if d.impl == nil {
d.impl = newOpenFileDialogImpl(d)
}
return invokeSyncWithResultAndError(d.impl.show)

var selection []string
var err error
if runtime.GOOS == "darwin" {
selection, err = d.impl.show()
} else {
selection, err = invokeSyncWithResultAndError(d.impl.show)
}
return selection, err
}

func (d *OpenFileDialogStruct) SetMessage(message string) *OpenFileDialogStruct {
Expand Down

0 comments on commit 9b81ea7

Please sign in to comment.