Emission hooks for parent-set signal.



I went into troubles adding an emission hook for parent-set signal. By
adding the hook, I receive a warning:

GLib-GObject-CRITICAL **: g_object_ref: assertion `object->ref_count >
0' failed
aborting...

Program received signal SIGABRT, Aborted.
0x00110416 in __kernel_vsyscall ()
(gdb) bt
#0  0x00110416 in __kernel_vsyscall ()
#1  0x00588660 in raise (sig=<value optimized out>)
at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#2  0x0058a028 in abort () at abort.c:88
#3  0x0044944c in g_logv () from /lib/libglib-2.0.so.0
#4  0x00449486 in g_log () from /lib/libglib-2.0.so.0
#5  0x004496eb in g_return_if_fail_warning () from /lib/libglib-2.0.so.0
#6  0x00b4d4db in g_object_ref () from /lib/libgobject-2.0.so.0
#7  0x00b4fa08 in ?? () from /lib/libgobject-2.0.so.0
#8  0x00b62a62 in g_signal_emit_valist () from /lib/libgobject-2.0.so.0
#9  0x00b631b6 in g_signal_emit () from /lib/libgobject-2.0.so.0
#10 0x010d2bc6 in gtk_widget_unparent ()
from /usr/lib/libgtk-x11-2.0.so.0
#11 0x0106bac0 in ?? () from /usr/lib/libgtk-x11-2.0.so.0
#12 0x09d68088 in ?? ()
#13 0x09da4838 in ?? ()
#14 0xbf879b38 in ?? ()
#15 0x00419790 in g_atomic_int_exchange_and_add ()
from /lib/libglib-2.0.so.0
#16 0x00b4d343 in g_object_unref () from /lib/libgobject-2.0.so.0
#17 0x00f912d6 in gtk_object_destroy ()
from /usr/lib/libgtk-x11-2.0.so.0
#18 0x010d2dad in gtk_widget_destroy ()
from /usr/lib/libgtk-x11-2.0.so.0
#19 0x00e55eb0 in ?? () from /usr/lib/libgtk-x11-2.0.so.0
#20 0x09dad000 in ?? ()
#21 0x00000000 in ?? ()
(gdb) 


Looking at the GTK source(2.12.11). What happens seems to be

(1) When I close a toplevel window, gtk_widget_destory is invoked.
(2) in gtk_widget_destroy, the toplevel window unref()s itself, then
unparent()s all of its children. The ref_count of the toplevel window
becomes zero.
(3) In gtk_widget_unparent, an parent-set signal is emitted, with the
destroying toplevel window as a parameter.
(4) g_signal_emit collects destroying toplevel and emit the hook. When
the toplevel is collected, a ref() is invoked, and the program gives the
warning.

I am not sure if this is correct, but apparently there is no way to fix
the problem unless I don't add a hook to parent-set.

Yu



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]