[gui] GdkPixbufDecoder JNIEnv fix proposal (PR/16824)

Mark Wielaard mark@klomp.org
Tue Aug 10 16:00:00 GMT 2004


Hi,

The following is a proposal to fix http://gcc.gnu.org/PR16824
"GdkPixbufDecoder crashes with image loading programs"

I decided to make it standalone and not depend on any of the other gtk
peer classes since it seems that it has to be useful even when no
GtkToolkit has been initialized. So it adds a static local JavaVM
reference to the file which is used in all funtions/callbacks that need
to access a JNI environment.

2004-08-08  Mark Wielaard  <mark@klomp.org>

        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c:
        #include gdk.h, not gtk.h. #include jni.h, native_state.h, string.h
        and stdlib.h, not gtkpeer.h.
        (*vm): New static variable.
        (areaPreparedID): Make static.
        (areaUpdatedID): Likewise.
        (area_prepared): Get and use JNIEnv through stored JavaVM *vm.
        (area_prepared): Likewise.
        (area_updated): Likewise.
        (closed): Likewise.
        (initStaticState): Initialize *vm javaVM.
        (pumpBytes): Use given env, not global gdk_env.

With this the new Frame.setIcon() and the mauve test for
gnu.testlet.java.awt.image.PixelGrabber.SimpleGrabber work much more
reliable.

The only issue is that gcc 3+ complains loudly about the following:

../../../../classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c: In function `area_prepared':
../../../../classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c:86: warning: dereferencing type-punned pointer will break strict-aliasing rules
../../../../classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c: In function `area_updated':
../../../../classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c:124: warning: dereferencing type-punned pointer will break strict-aliasing rules
../../../../classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c: In function `closed':
../../../../classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkPixbufDecoder.c:167: warning: dereferencing type-punned pointer will break strict-aliasing rules

Does anybody know what the correct way to solve this is?
Any comments on the general idea of the patch?

Cheers,

Mark
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GdkPixbufDecoder.patch
Type: text/x-patch
Size: 4676 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20040810/46edd67b/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://gcc.gnu.org/pipermail/java-patches/attachments/20040810/46edd67b/attachment.sig>


More information about the Java-patches mailing list