gtkmozembed segfault

时间:2011-09-11 15:28:43

标签: c gtk xulrunner

我无法让gtkmozembed工作:

#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gtkmozembed.h>
#include <stdlib.h>
#include <stdio.h>
static void destroy( GtkWidget *widget,
                     gpointer   data )
{   
    gtk_main_quit ();
}

int main( int   argc,
          char *argv[] )
{   
    GtkWidget *window, *mozwidget;

    gtk_init (&argc, &argv);

    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect (window, "destroy",
                      G_CALLBACK (destroy), NULL);

    mozwidget=gtk_moz_embed_new();

    gtk_moz_embed_load_url (GTK_MOZ_EMBED(mozwidget),"http://www.google.com");

    gtk_container_add (GTK_CONTAINER (window), mozwidget);

       //last line running correctly
    gtk_widget_show_all(window);
       //not running anything after this line

    gtk_window_set_skip_taskbar_hint(GTK_WINDOW(window),TRUE);
    gtk_window_set_type_hint(GTK_WINDOW(window),GDK_WINDOW_TYPE_HINT_DOCK),
    gtk_window_set_skip_pager_hint(GTK_WINDOW(window),TRUE);
    gtk_window_set_keep_below(GTK_WINDOW(window),TRUE);
    gtk_window_set_decorated(GTK_WINDOW(window),FALSE);
    gtk_window_stick(GTK_WINDOW(window));

    gtk_main ();

    return 0;
}

我使用编译:

gcc -g main.c -o xulwidget $(pkg-config --cflags --libs gtk+-2.0) -I /usr/include/xulrunner-2.0 -L /usr/lib/xulrunner-2.0 -lxul

错误:第30行周围的分段错误(参见上面的评论)

Stacktrace(没有xul和gtk的调试库):

#0  0x00007ffff3b2fc05 in ?? () from //usr/lib64/xulrunner-2.0/libxul.so
#1  0x00007ffff3b2e706 in ?? () from //usr/lib64/xulrunner-2.0/libxul.so
#2  0x00007ffff58da1ae in g_closure_invoke () from /usr/lib64/libgobject-2.0.so.0
#3  0x00007ffff58efa68 in ?? () from /usr/lib64/libgobject-2.0.so.0
#4  0x00007ffff58f15f4 in g_signal_emit_valist () from /usr/lib64/libgobject-2.0.so.0
#5  0x00007ffff58f1b73 in g_signal_emit () from /usr/lib64/libgobject-2.0.so.0
#6  0x00007ffff7a253a7 in gtk_widget_realize () from /usr/lib64/libgtk-x11-2.0.so.0
#7  0x00007ffff7a25b98 in gtk_widget_map () from /usr/lib64/libgtk-x11-2.0.so.0
#8  0x00007ffff7a3644a in ?? () from /usr/lib64/libgtk-x11-2.0.so.0
#9  0x00007ffff58da1ae in g_closure_invoke () from /usr/lib64/libgobject-2.0.so.0
#10 0x00007ffff58efa68 in ?? () from /usr/lib64/libgobject-2.0.so.0
#11 0x00007ffff58f15f4 in g_signal_emit_valist () from /usr/lib64/libgobject-2.0.so.0
#12 0x00007ffff58f1b73 in g_signal_emit () from /usr/lib64/libgobject-2.0.so.0
#13 0x00007ffff7a25b6e in gtk_widget_map () from /usr/lib64/libgtk-x11-2.0.so.0
#14 0x00007ffff7a36580 in ?? () from /usr/lib64/libgtk-x11-2.0.so.0
#15 0x00007ffff58da1ae in g_closure_invoke () from /usr/lib64/libgobject-2.0.so.0
#16 0x00007ffff58efa68 in ?? () from /usr/lib64/libgobject-2.0.so.0
#17 0x00007ffff58f15f4 in g_signal_emit_valist () from /usr/lib64/libgobject-2.0.so.0
#18 0x00007ffff58f1b73 in g_signal_emit () from /usr/lib64/libgobject-2.0.so.0
#19 0x00007ffff7a262e3 in gtk_widget_show () from /usr/lib64/libgtk-x11-2.0.so.0
#20 0x0000000000400f11 in main (argc=1, argv=0x7fffffffd8f8) at main.c:29

1 个答案:

答案 0 :(得分:1)

自4.0以来,Mozilla不再可嵌入。

不要尝试,使用GtkWebkit,如果你在Windows / MacOSX上需要它,那么维护人员就不应该让他们不依赖于单一平台。