RE: [Java-gnome-developer] CVS: Problem with gdk_BaseObject.c and GTK_IS_OBJECT()
Brought to you by:
afcowie
From: Jeffrey M. <Jef...@Br...> - 2001-10-09 19:27:35
|
I have struggled with this issue for some time and as yet haven't found a solution. I need to determine if a void pointer is actually pointing to a GTK type. All macros and methods in GTK assume this is the case (like the GTK_IS_OBJECT macro below). Does anybody have a suggestion? -Jeff > > In CVS version, in other/gdk_BaseObject.c: > > jobject makeBaseObjectSubclass (JNIEnv *env, jclass cls, void *peer) > { > if (peer == NULL) > return NULL; > else if (GTK_IS_OBJECT(peer)) > return makeBaseObjectClass(env, peer); > else { > jobject result = (*env)->AllocObject (env, cls); > jlong result_jl; > > *(void **) &result_jl = peer; > (*env)->SetLongField (env, result, nativepeerFid, result_jl); > return result; > } > } > > The GTK_IS_OBJECT is a problem, if you try to create any > object not based > on Gtk, like GdkGC: > > xx = new GdkGC(yy); > > leads to: > > Program received signal SIGSEGV, Segmentation fault. > 0x41383ed6 in makeBaseObjectSubclass (env=0x400887d4, cls=0x6, > peer=0x81244f8) > at other/gdk_BaseObject.c:70 > 70 else if (GTK_IS_OBJECT(peer)) > > This, of course happens because "peer" in this context is not a Gtk > object, but instead a GdkWindow, which isn't representable in the Gtk > object system: > > (gdb) p *(GdkGC*)peer > $14 = {dummy_var = 1701080693} > (gdb) p *((GtkObject*)peer) > $15 = {klass = 0x65646e75, flags = 135415064, ref_count = 135220712, > object_data = 0x1} > (gdb) p *((GtkObject*)peer)->klass > Cannot access memory at address 0x65646e75 > > In noticed the GTK_IS_OBJECT was added in version 1.5 (of that file). > Apparently this hasn't been noticed since the test and sample programs > don't use GdkGC directly at all.. > > -- > sa...@ik... I have become death, > destroyer of the worlds. > > > _______________________________________________ > java-gnome-developer mailing list > jav...@li... > https://lists.sourceforge.net/lists/listinfo/java-gnome-developer > |