Skip to content

Commit

Permalink
fix panic in QWidget.Actions, therecipe#1286
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Apr 1, 2023
1 parent c0c124a commit c1f8def
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions widgets/widgets.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/therecipe/qt/gui"
"github.com/therecipe/qt/internal"
"github.com/therecipe/qt/interop/gow"
"log"
"unsafe"
)

Expand Down Expand Up @@ -58414,10 +58415,22 @@ func (ptr *QWidget) ActionEventDefault(event gui.QActionEvent_ITF) {
}

func (ptr *QWidget) Actions() []*QAction {

return internal.CallLocalFunction([]interface{}{"", uintptr(ptr.Pointer()), ptr.QObject_PTR().ClassNameInternalF(), "Actions"}).([]*QAction)
actionsIface := internal.CallLocalFunction([]interface{}{"", uintptr(ptr.Pointer()), ptr.QObject_PTR().ClassNameInternalF(), "Actions"})
switch actionsTyped := actionsIface.(type) {
case []*QAction:
return actionsTyped
case []interface{}:
actions := make([]*QAction, len(actionsTyped))
for index, actionIface := range actionsTyped {
actions[index] = actionIface.(*QAction)
}
return actions
}
log.Printf("unexpected type in QWidget.Actions(): %#v", actionsIface)
return []*QAction{}
}


func (ptr *QWidget) ActivateWindow() {

internal.CallLocalFunction([]interface{}{"", uintptr(ptr.Pointer()), ptr.QObject_PTR().ClassNameInternalF(), "ActivateWindow"})
Expand Down

0 comments on commit c1f8def

Please sign in to comment.