Skip to content
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

🐛 Fix panic while accessing selected files #1207

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all 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
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