2

运行我的应用程序时出现此错误

GLib-GObject-WARNING **: gtype.c:3119: invalid class pointer `0xdfbb60'

它通常发生在将GooCanvasGroup对象的子类传递给函数期望 a GooCanvasItem(这是一个接口类)时,但它不会在该特定点失败,而是在库中失败。

<cut> 
classes : 0xc73cb0 0xc73cb0 
<cut>
classes : 0xff3250 0xff3250 

(oregano:8482): GLib-GObject-WARNING **: gtype.c:3119: invalid class pointer `0x100a330'

Program received signal SIGTRAP, Trace/breakpoint trap.
0x00007ffff701ba27 in g_logv () from /usr/lib/libglib-2.0.so.0
(gdb) 
(gdb) bt
#0  0x00007ffff701ba27 in g_logv () from /usr/lib/libglib-2.0.so.0
#1  0x00007ffff701bbf2 in g_log () from /usr/lib/libglib-2.0.so.0
#2  0x00007ffff72f1dbd in g_type_interface_peek ()
   from /usr/lib/libgobject-2.0.so.0
#3  0x00007ffff7baf3dc in goo_canvas_item_update (item=0xb6c490, 
    entire_tree=entire_tree@entry=0, cr=cr@entry=0x7583d0, bounds=bounds@entry=
    0x7fffffffd3b0) at goocanvasitem.c:1698
#4  0x00007ffff7babbaf in goo_canvas_group_update (item=0xb6c370, entire_tree=
    0, cr=0x7583d0, bounds=0x7fffffffd440) at goocanvasgroup.c:615
#5  0x00007ffff7baf3ed in goo_canvas_item_update (item=0xb6c370, 
    entire_tree=entire_tree@entry=0, cr=cr@entry=0x7583d0, bounds=bounds@entry=
    0x7fffffffd440) at goocanvasitem.c:1700
#6  0x00007ffff7babbaf in goo_canvas_group_update (item=0xb6c130, entire_tree=
    0, cr=0x7583d0, bounds=0x7fffffffd4f0) at goocanvasgroup.c:615
#7  0x00007ffff7baf3ed in goo_canvas_item_update (item=0xb6c130, 
    entire_tree=entire_tree@entry=0, cr=cr@entry=0x7583d0, bounds=bounds@entry=
    0x7fffffffd4f0) at goocanvasitem.c:1700
#8  0x00007ffff7bc9425 in goo_canvas_update_internal (canvas=canvas@entry=
    0xc6e0d0, cr=cr@entry=0x7583d0) at goocanvas.c:2560
#9  0x00007ffff7bc9492 in goo_canvas_update (canvas=0xc6e0d0)
    at goocanvas.c:2592
#10 0x00007ffff7baf3a4 in goo_canvas_item_ensure_updated (item=item@entry=
    0xf0e670) at goocanvasitem.c:1676
#11 0x00007ffff7bb46e9 in goo_canvas_item_simple_get_bounds (item=0xf0e670, 
    bounds=0x7fffffffd640) at goocanvasitemsimple.c:1013
#12 0x00007ffff7baf21d in goo_canvas_item_get_bounds (item=0xf0e670, bounds=
    0x7fffffffd640) at goocanvasitem.c:1546
#13 0x000000000043ee77 in create_canvas_items (group=0xde4250, library_part=
    0x8be100) at ../../src/sheet/part-item.c:1176
#14 0x000000000043e841 in part_item_new (sheet=0xc6e0d0, part=0x10095c0)
    at ../../src/sheet/part-item.c:1083
#15 0x0000000000440bff in sheet_item_factory_create_sheet_item (sheet=
    0xc6e0d0, data=0x10095c0) at ../../src/sheet/sheet-item-factory.c:58
#16 0x000000000044730b in sheet_add_ghost_item (sheet=0xc6e0d0, data=0x10095c0)
    at ../../src/sheet/sheet.c:1139
#17 0x000000000042f610 in place_cmd (widget=0xcf9030, br=0xc8bb00)
    at ../../src/part-browser.c:191
#18 0x00007ffff72d3467 in ?? () from /usr/lib/libgobject-2.0.so.0
#19 0x00007ffff72ebe66 in g_signal_emit_valist ()
   from /usr/lib/libgobject-2.0.so.0
#20 0x00007ffff72ec6b2 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#21 0x00007ffff69db198 in ?? () from /usr/lib/libgtk-3.so.0
#22 0x00007ffff72d3467 in ?? () from /usr/lib/libgobject-2.0.so.0
#23 0x00007ffff72ebe66 in g_signal_emit_valist ()
   from /usr/lib/libgobject-2.0.so.0
#24 0x00007ffff72ec6b2 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#25 0x00007ffff69d9f03 in ?? () from /usr/lib/libgtk-3.so.0
#26 0x00007ffff6aa8f3f in ?? () from /usr/lib/libgtk-3.so.0
#27 0x00007ffff72d3467 in ?? () from /usr/lib/libgobject-2.0.so.0
#28 0x00007ffff72ebe66 in g_signal_emit_valist ()

我手动验证了类指针是错误的(阅读:没有 goocanvas、sheet-item、part-item 类)

使该问题浮出水面的最后一个电话是

            // the group is a "part-item" a subclass of "sheet-item" which is 
            // subclassed from "GooCanvasGroup"
    item = goo_canvas_polyline_new (GOO_CANVAS_ITEM (group), ... );

    g_assert (item!=NULL);
    g_assert (GOO_IS_CANVAS_ITEM (item));

    g_assert (group!=NULL);
    g_assert (GOO_IS_CANVAS_GROUP (group));
    g_assert (GOO_CANVAS_GROUP_GET_CLASS (group)!=NULL);
    g_printf ("classes : %p %p \n", GOO_CANVAS_GROUP_GET_CLASS(group), PART_ITEM_GET_CLASS (group));

    goo_canvas_item_get_bounds (item, &bounds);

但是,一旦我删除goo_canvas_item_...-call ,下一次调用 agoo_canvas_..就会失败。

所以我怀疑类声明/类型定义中有问题:

工作表项目.c

G_DEFINE_TYPE (SheetItem, sheet_item, GOO_TYPE_CANVAS_GROUP)

部分项目.c

G_DEFINE_TYPE (PartItem, part_item, TYPE_SHEET_ITEM)

完整文件在这里:

https://github.com/drahnr/oregano/blob/master/src/sheet/sheet-item.c https://github.com/drahnr/oregano/blob/master/src/sheet/sheet-item.h https://github.com/drahnr/oregano/blob/master/src/sheet/part-item.c https://github.com/drahnr/oregano/blob/master/src/sheet/part-item.h

我很困惑是什么导致了这个问题,所以任何形式的提示都值得赞赏。

编辑:如果有人想自己尝试:

git clone git://github.com/drahnr/oregano.git
cd oregano
waf configure --prefix=/tmp debug install
gdb ./build/debug/oregano
(gdb) r
## click to time on the "place item"-button on the right side (bottom)
(gdb) bt
4

0 回答 0