Skip to content

Commit

Permalink
🐛 Fix panic while accessing selected files
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-drprasad committed Jan 7, 2021
1 parent c0c124a commit 6b5e216
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions widgets/widgets.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
package widgets

import (
"unsafe"

"github.com/therecipe/qt/core"
"github.com/therecipe/qt/gui"
"github.com/therecipe/qt/internal"
"github.com/therecipe/qt/interop/gow"
"unsafe"
)

type QAbstractButton struct {
Expand All @@ -19,6 +20,23 @@ type QAbstractButton_ITF interface {
QAbstractButton_PTR() *QAbstractButton
}

func interfaceToStringArray(i interface{}) []string {
switch i.(type) {
case interface{}:
return i.([]string)

case []interface{}:
ifs := i.([]interface{})
o := []string{}
for _, fn := range ifs {
o = append(o, fn.(string))
}
return o
default:
panic("expected interface or []interface, but got something else")
}
}

func (ptr *QAbstractButton) QAbstractButton_PTR() *QAbstractButton {
return ptr
}
Expand Down Expand Up @@ -13049,12 +13067,12 @@ func (ptr *QFileDialog) GetOpenFileName(parent QWidget_ITF, caption string, dir

func QFileDialog_GetOpenFileNames(parent QWidget_ITF, caption string, dir string, filter string, selectedFilter string, options QFileDialog__Option) []string {

return internal.CallLocalFunction([]interface{}{"", "", "widgets.QFileDialog_GetOpenFileNames", "", parent, caption, dir, filter, selectedFilter, options}).([]string)
return interfaceToStringArray(internal.CallLocalFunction([]interface{}{"", "", "widgets.QFileDialog_GetOpenFileNames", "", parent, caption, dir, filter, selectedFilter, options}))
}

func (ptr *QFileDialog) GetOpenFileNames(parent QWidget_ITF, caption string, dir string, filter string, selectedFilter string, options QFileDialog__Option) []string {

return internal.CallLocalFunction([]interface{}{"", "", "widgets.QFileDialog_GetOpenFileNames", "", parent, caption, dir, filter, selectedFilter, options}).([]string)
return interfaceToStringArray(internal.CallLocalFunction([]interface{}{"", "", "widgets.QFileDialog_GetOpenFileNames", "", parent, caption, dir, filter, selectedFilter, options}))
}

func QFileDialog_GetOpenFileUrl(parent QWidget_ITF, caption string, dir core.QUrl_ITF, filter string, selectedFilter string, options QFileDialog__Option, supportedSchemes []string) *core.QUrl {
Expand Down Expand Up @@ -13189,7 +13207,7 @@ func (ptr *QFileDialog) SelectUrl(url core.QUrl_ITF) {

func (ptr *QFileDialog) SelectedFiles() []string {

return internal.CallLocalFunction([]interface{}{"", uintptr(ptr.Pointer()), ptr.ClassNameInternalF(), "SelectedFiles"}).([]string)
return interfaceToStringArray(internal.CallLocalFunction([]interface{}{"", uintptr(ptr.Pointer()), ptr.ClassNameInternalF(), "SelectedFiles"}))
}

func (ptr *QFileDialog) SelectedMimeTypeFilter() string {
Expand Down

0 comments on commit 6b5e216

Please sign in to comment.