go-gtk icon indicating copy to clipboard operation
go-gtk copied to clipboard

Example treeview and listview don't work

Open ghost opened this issue 11 years ago • 6 comments

At the listview example I get the Error:

unexpected fault address 0xffffffffa404d7e6
throw: fault
[signal 0xb code=0x1 addr=0xffffffffa404d7e6 pc=0x7fe6aeb0e102]

goroutine 1 [syscall]:
github.com/mattn/go-gtk/gtk._Cfunc_gtk_list_store_newv(0x7fe600000003, 0x7fe6a4049d80)
    /tmp/go-build859929456/github.com/mattn/go-gtk/gtk/_obj/_cgo_defun.c:8442 +0x2f
github.com/mattn/go-gtk/gtk.NewListStore(0x7fe6aeebbf40, 0x300000003, 0x0, 0xa404d7d0, 0x420cca, ...)
    /tmp/go-build859929456/github.com/mattn/go-gtk/gtk/_obj/_cgo_gotypes.go:8279 +0xef
main.main()
    /home/tobias/go/src/pkg/github.com/mattn/go-gtk/example/listview/listview.go:18 +0x1cc

goroutine 2 [syscall]:
created by runtime.main
    /home/tobias/go/src/pkg/runtime/proc.c:221
exit status 2

At the treeview example I get the Error:

unexpected fault address 0x404d7e6
throw: fault
[signal 0xb code=0x1 addr=0x404d7e6 pc=0x7f2911d04102]

goroutine 1 [syscall]:
github.com/mattn/go-gtk/gtk._Cfunc_gtk_tree_store_newv(0x7f2900000002, 0x7f2904049d80)
    /tmp/go-build859929456/github.com/mattn/go-gtk/gtk/_obj/_cgo_defun.c:5146 +0x2f
github.com/mattn/go-gtk/gtk.NewTreeStore(0x7f2912be6f60, 0x200000002, 0x0, 0x40, 0x41ab45, ...)
    /tmp/go-build859929456/github.com/mattn/go-gtk/gtk/_obj/_cgo_gotypes.go:8395 +0xef
main.main()
    /home/tobias/go/src/pkg/github.com/mattn/go-gtk/example/treeview/treeview.go:19 +0x1a9

goroutine 2 [syscall]:
created by runtime.main
    /home/tobias/go/src/pkg/runtime/proc.c:221
exit status 2

ghost avatar Mar 29 '13 13:03 ghost

What OS do you use? CPU?

mattn avatar Mar 31 '13 17:03 mattn

I use linux 3.5.0-17-generic 64bit on an AMD Athlon Neo

ghost avatar Apr 01 '13 10:04 ghost

I have experienced this exact issue on a similar configuration. The problem must be in the third column of the list, where it should display an icon; when I changed it to the integer type the program compiled and ran without any errors.

edit: Actually, changing the type of the third column to anything but pixbuf makes it work; obviously, "makes it work" refers only to those programs that don't need images in their lists...

nkrs avatar Apr 10 '13 17:04 nkrs

I had a problem with this too. I think it is something fishy with the gdkpixbuf.GetType() parameter. I was looking into it some time ago and I wonder if the "icon" type needs to be correctly registered with glib or something. I'm not sure as I am not a GTK expert, but it looks like go-gtk3 does something like that.

bytting avatar Apr 10 '13 17:04 bytting

If you look at the init function in gdkpixbuf in go-gtk3 he does something like this

func init() { // Initialize G_TYPE_PIXBUF G_TYPE_PIXBUF = gobject.GType(C.gdk_pixbuf_get_type())

    // Register Pixbuf type
gobject.RegisterCType(G_TYPE_PIXBUF, newPixbufFromNative)
gobject.RegisterGoType(G_TYPE_PIXBUF, nativeFromPixbuf)

// Initialize GdkInterp
GdkInterp.NEAREST = 0
GdkInterp.TILES = 1
GdkInterp.BILINEAR = 2
GdkInterp.HYPER = 3

}

I was hoping to get something out of that, but I never got to it

bytting avatar Apr 10 '13 17:04 bytting

This is definetly related to the pixbuf. The following patch stops the demo from crashing for me:

diff --git a/example/listview/listview.go b/example/listview/listview.go
index 409d6c2..a556acc 100644
--- a/example/listview/listview.go
+++ b/example/listview/listview.go
@@ -4,7 +4,6 @@ import (
 	"os"
 	"unsafe"
 
-	"github.com/mattn/go-gtk/gdkpixbuf"
 	"github.com/mattn/go-gtk/glib"
 	"github.com/mattn/go-gtk/gtk"
 )
@@ -17,7 +16,7 @@ func main() {
 
 	swin := gtk.NewScrolledWindow(nil, nil)
 
-	store := gtk.NewListStore(glib.G_TYPE_STRING, glib.G_TYPE_BOOL, gdkpixbuf.GetType())
+	store := gtk.NewListStore(glib.G_TYPE_STRING, glib.G_TYPE_BOOL)
 	treeview := gtk.NewTreeView()
 	swin.Add(treeview)
 
diff --git a/example/treeview/treeview.go b/example/treeview/treeview.go
index 802cf78..3618a79 100644
--- a/example/treeview/treeview.go
+++ b/example/treeview/treeview.go
@@ -1,7 +1,6 @@
 package main
 
 import (
-	"github.com/mattn/go-gtk/gdkpixbuf"
 	"github.com/mattn/go-gtk/glib"
 	"github.com/mattn/go-gtk/gtk"
 	"os"
@@ -16,7 +15,7 @@ func main() {
 
 	swin := gtk.NewScrolledWindow(nil, nil)
 
-	store := gtk.NewTreeStore(gdkpixbuf.GetType(), glib.G_TYPE_STRING)
+	store := gtk.NewTreeStore(glib.G_TYPE_STRING)
 	treeview := gtk.NewTreeView()
 	swin.Add(treeview)
 

jgkamat avatar Nov 11 '17 22:11 jgkamat