Oops, the garbage collector is collecting our GTK+ idle callback too (much later than it did the other callbacks). Fixed.

This commit is contained in:
Pietro Gagliardi 2014-03-07 09:10:14 -05:00
parent ded390adb9
commit 61726d5cdd
1 changed files with 4 additions and 3 deletions

View File

@ -24,7 +24,11 @@ func gtk_init() bool {
return fromgbool(C.gtk_init_check((*C.int)(nil), (***C.char)(nil))) return fromgbool(C.gtk_init_check((*C.int)(nil), (***C.char)(nil)))
} }
// the garbage collector has been found to eat my callback functions; this will stop it
var callbackstore = make([]*func() bool, 0, 50)
func gdk_threads_add_idle(what func() bool) { func gdk_threads_add_idle(what func() bool) {
callbackstore = append(callbackstore, &what)
C.gdk_threads_add_idle(callbacks["idle"], C.gpointer(unsafe.Pointer(&what))) C.gdk_threads_add_idle(callbacks["idle"], C.gpointer(unsafe.Pointer(&what)))
} }
@ -41,9 +45,6 @@ func gtk_window_new() *gtkWidget {
return fromgtkwidget(C.gtk_window_new(0)) return fromgtkwidget(C.gtk_window_new(0))
} }
// the garbage collector has been found to eat my callback functions; this will stop it
var callbackstore = make([]*func() bool, 0, 50)
func g_signal_connect(obj *gtkWidget, sig string, callback func() bool) { func g_signal_connect(obj *gtkWidget, sig string, callback func() bool) {
callbackstore = append(callbackstore, &callback) callbackstore = append(callbackstore, &callback)
ccallback := callbacks[sig] ccallback := callbacks[sig]