segfault using a custom subclass of goocanvas.ItemModelSimple

Bug #295952 reported by Michael Gratton
2
Affects Status Importance Assigned to Milestone
pygoocanvas
Invalid
Undecided
Unassigned

Bug Description

Creating a custom model by subclassing goocanvas.ItemModelSimple then adding it to the canvas causes a segfault:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb7ead8c0 (LWP 3469)]
0x00000000 in ?? ()
(gdb) bt
#0 0x00000000 in ?? ()
#1 0xb6f3604e in ?? () from /usr/lib/libgoocanvas.so.3
#2 0xb7d9c11c in g_cclosure_marshal_VOID () from /usr/lib/libgobject-2.0.so.0
#3 0xb7d8ec4b in g_closure_invoke () from /usr/lib/libgobject-2.0.so.0
#4 0xb7da5095 in ?? () from /usr/lib/libgobject-2.0.so.0
#5 0xb7da67ac in g_signal_emit_valist () from /usr/lib/libgobject-2.0.so.0
#6 0xb7da6c26 in g_signal_emit () from /usr/lib/libgobject-2.0.so.0
#7 0xb6f3ba86 in _goo_canvas_item_model_emit_child_added ()
   from /usr/lib/libgoocanvas.so.3
#8 0xb6f35b90 in ?? () from /usr/lib/libgoocanvas.so.3
#9 0xb6f3d03e in goo_canvas_item_model_add_child ()
   from /usr/lib/libgoocanvas.so.3
#10 0xb6f7a984 in ?? ()
   from /var/lib/python-support/python2.5/goocanvasmodule.so
#11 0x080cea39 in PyEval_EvalFrameEx (f=0x97c23d4, throwflag=0)
    at ../Python/ceval.c:3595
#12 0x080cfbf5 in PyEval_EvalFrameEx (f=0x9595e54, throwflag=0)
    at ../Python/ceval.c:3681
[snip]

In the attached sample program, the segfault occurs at line 47, where the custom instance is added to the root group model.

I couldn't find any examples of what the custom model class should look like, but I based its implementation of create_item() on goocanvas's GroupModel class. Note that the segfault seems to occur before calling that however, as the print statement on line 15 never shows up in the output.

Revision history for this message
Michael Gratton (mjog) wrote :
Revision history for this message
Michael Gratton (mjog) wrote :

Oh, I'm using the latest packages in Intrepid:

python-pygoocanvas 0.12.0-0ubuntu1
libgoocanvas-common 0.12-0ubuntu1
libgoocanvas3 0.12-0ubuntu1
python-gtk2 2.13.0-0ubuntu8
libgtk2.0-0 2.14.4-0ubuntu1
python2.5 2.5.2-11.1ubuntu1

Revision history for this message
Gian Mario Tagliaretti (gianmt) wrote :

Mike you should modify you example like this

class CustomModel(goocanvas.ItemModelSimple, goocanvas.ItemModel):

    def __init__(self, **props):
        super(CustomModel, self).__init__(**props)

    def do_create_item(self, canvas):
        print "Creating item..."
        rect = goocanvas.Rect(x=0, y=0,
                              width=100, height=50,
                              line_width=2.0,
                              stroke_color='black')
        rect.set_canvas(canvas)
        rect.set_model(self)
        return rect

and it should work

Revision history for this message
Michael Gratton (mjog) wrote :

Ahh, I think I remember seeing something like needing "do_..." in front of the overridden names in pygtk. Is that documented somewhere? In any case, that explains a lot, thanks.

Feel free to take the fixed version of the example and add it to pygoocanvas's demos, it might help someone else.

Revision history for this message
Michael Gratton (mjog) wrote :

Not a bug in pygoocanvas.

Changed in pygoocanvas:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.