diamondburned/gotk4

TreeView row-activated signal handler - conversion failure

pekim opened this issue · 6 comments

pekim commented
view := gtk.NewTreeView()
view.ConnectRowActivated(func(path *gtk.TreePath, column gtk.TreeViewColumn) {
	fmt.Println(path.String())
})

When the row-activated signal is triggered, the column argument is not converted to the correct type, resulting in a panic.

panic: reflect.Value.Convert: value of type *gtk.TreeViewColumn cannot be converted to type gtk.TreeViewColumn [recovered]
	panic: closure error: unexpected panic caught: reflect.Value.Convert: value of type *gtk.TreeViewColumn cannot be converted to type gtk.TreeViewColumn
pekim commented

I can workaround this for now as I don't currently need to know the column.

view := gtk.NewTreeView()
view.Connect("row-activated", func(path *gtk.TreePath) {
	fmt.Println("activated", path.String())
})

This has to do with the code generator being weird with the edge cases. The correct function signature is

view.Connect("row-activated", func(path *gtk.TreePath, column *gtk.TreeViewColumn) {
	fmt.Println(path.String())
})

I think this should be fixed along with #58, since the signature generation should be a lot more correct if it's generated with the type converter.

pekim commented

This now works, which is great.

view.Connect("row-activated", func(path *gtk.TreePath, column *gtk.TreeViewColumn) {
	fmt.Println(path.String())
})

However it's worth noting that the original conversion issue with ConnectRowActivated still remains. That's probably not too surprising as the function's signature has not changed.

@pekim can you recheck this? The generated function signature for this signal should now be

func (treeView *TreeView) ConnectRowActivated(f func(path *TreePath, column *TreeViewColumn)) externglib.SignalHandle

which is the correct signature.

pekim commented

Yes, it's good now. Thank you.