Re: GTK is not correctly initialized

CAPITAINE Harold <[email protected]> Wed, 20 Jun 2007 15:24:08 -0000
Newsgroups gmane.comp.mozilla.devel.java
Organization http://groups.google.com
Message-ID <1182353048.555109.10870__16730.6730793372$1182353123$gmane$org@g4g2000hsf.googlegroups.com>
On 12 juin, 19:11, Greg Bowyer <[email protected]> wrote:
> [email protected] wrote:
> > Hi devs,
>
> > I'm currently experiencing some difficulties to manage to make gecko
> > working with javaxpcom with a linux system.
>
> > I've browsed internet, read approximately everything that I could, and
> > I finally understood the history of embedded gecko in applications.
>
> > But the problem is that many newbies  like me, have the initialization
> > problem of gtk.
>
> > Here is the stack that I've got:
>
> > (process:27935): GLib-GObject-CRITICAL **: gtype.c:2242:
> > initialization assertion failed, use IA__g_type_init() prior to this
> > function
>
> > (process:27935): Gdk-CRITICAL **: gdk_screen_get_rgb_visual: assertion
> > `GDK_IS_SCREEN (screen)' failed
> > #
> > # An unexpected error has been detected by HotSpot Virtual Machine:
> > #
> > #  SIGSEGV (0xb) at pc=0xa8c53727, pid=27935, tid=3085039296
> > #
> > # Java VM: Java HotSpot(TM) Client VM (1.5.0_11-b03 mixed mode)
> > # Problematic frame:
> > # C  [libxul.so+0xcb9727]  _ZN9nsToolkit14CreateSharedGCEv+0x23
> > #
> > # An error report file with more information is saved as
> > hs_err_pid27935.log
> > #
> > # If you would like to submit a bug report, please visit:
> > #  http://java.sun.com/webapps/bugreport/crash.jsp
> > #
>
> > So I tried to change the version of the xpcom lib and used the one
> > compiled for gtk, no way iit doesn't work.
>
> > So is anyone knows what I have to do? Do I have to configure something
> > on my system, or add a library.
>
> Hey there, I too indeed have had this same problem. Basically what it
> boils down to is GTK is throwing its toys out of the pram when it comes
> to checking if it is initialised or not. What you need is someway to
> init gtk *before* you kick off mozilla.
>
> I belive the bugs from the mozilla crew are
>   *https://bugzilla.mozilla.org/show_bug.cgi?id=342691and
>   *https://bugzilla.mozilla.org/show_bug.cgi?id=343039
>
> There are a couple of ways you can pull this off:
>         1) Load up SWT as on linux this will kick off GTK+
>         2) Ditto with Java-GTK
>         3) Small method call to gtk_init in C land (welcome to JNI)
>
> I used the last version and thus my code for this is something like
>
> SNIP - C File
> -------------------------------------------------------------------
> #include <gtk/gtk.h>
> #include "com_opodo_siterunner_xulrunner_GtkStub.h"
>
> JNIEXPORT void JNICALL Java_com_opodo_siterunner_xulrunner_GtkStub_gtk_1init
>    (JNIEnv *jniEnv, jclass clazz) {
>
>         // the gdk / gtk code will function fine without this
>         gtk_init(0, NULL);}
>
> -------------------------------------------------------------------
>
> SNIP - Java Code
> -------------------------------------------------------------------
> public class GtkStub {
>
>      /**
>       * Method that, very basically calls gtk_init(0,NULL) in C land
>       * so that GTK is correctly initalised for the XULRunner
>       * application
>       */
>       private static native final void gtk_init();}
>
> -------------------------------------------------------------------

Thanks you're the man who makes me keeping my job ;)
Thanks a lot