unexpected segfault removing elements

Bug #103412 reported by Rob Caskey
2
Affects Status Importance Assigned to Milestone
pygoocanvas
Invalid
Undecided
Unassigned

Bug Description

uncomment the #self.drawables.remove() line blow to get the nice crash, this is using HEAD as of 4/4

#!/usr/bin/python
import goocanvas
import gtk

class Stack(goocanvas.Group):
    cards = []
    drawables = None
    def __init__(self, root):
 self.drawables = goocanvas.Group(parent = root)
    def append(self, card):
 self.cards.append(card)
 card.parent = self
 for x in self.cards:
     x.draw(self.drawables)
 #self.drawables.remove()

class Card:
    width = 200
    height = 300
    border = 12
    border_color = "gray"
    background_color = "tan"
    backside_color = "brown"
    flipped = False
    title = None
    drawables = None
    def __init__(self, title = None):
 self.title = title
    def draw(self, root):
 self.drawables = goocanvas.Group(parent = root)
 goocanvas.Rect (parent = self.drawables, x = 0, y = 0, width = self.width, height = self.height, fill_color = self.border_color)
 if self.flipped:
  goocanvas.Rect (parent = self.drawables, x = self.border, y = self.border, width = self.width - (2 * self.border), height = self.height - (2 * self.border), fill_color = self.backside_color)
 else:
  goocanvas.Rect (parent = self.drawables, x = self.border, y = self.border, width = self.width - (2 * self.border), height = self.height - (2 * self.border), fill_color = self.background_color)
  if self.title is not None: text = goocanvas.Text(parent = self.drawables, text = self.title, x = self.border * 1.5, y = self.border * 1.5)
def setup_canvas (canvas):

    root = canvas.get_root_item ()

    s = Stack(root)
    for i in range(10):
     s.append(Card(title = "TEST " + str(i)))

def create_card_page ():
    vbox = gtk.VBox (False, 4)
    vbox.set_border_width (4)

    hbox = gtk.HBox (False, 4)
    vbox.pack_start (hbox, False, False, 0)

    scrolled_win = gtk.ScrolledWindow ()
    scrolled_win.set_shadow_type (gtk.SHADOW_IN)

    vbox.add (scrolled_win)

    canvas = goocanvas.Canvas ()
    canvas.set_size_request (600, 450)
    canvas.set_bounds (0, 0, 1000, 1000)

    scrolled_win.add (canvas)

    setup_canvas (canvas)

    return vbox

def main ():
    v = create_card_page ()

    w = gtk.Window()
    w.connect("destroy", gtk.main_quit)
    w.add(v)
    w.show_all()

    gtk.main()

if __name__ == "__main__":
    main()

Revision history for this message
Rob Caskey (rcaskey) wrote :

(card.py:6705): GooCanvas-CRITICAL **: goo_canvas_create_cairo_context: assertion `canvas->canvas_window != NULL' failed

should have mentioned the actual error, which is above

also attaching the source file

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

This is a well know bug in goocanvas, not in pygoocanvas itself.

To work around this issue create and show the canvas *before* to do any other thing, this way the canvas->canvas_window will be created.

Let us know if the workaround will solve your issue.

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

Other bug subscribers

Bug attachments

Remote bug watches

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