To continue the theme: attached is a short script that also segfaults.
Mess with the block1 and block2 vars to see the problem -- at least I *hope* you see it, because I don't want to feel special :)

\d
--
Fonty Python and Things! -- http://otherwise.relics.co.za/wiki/Software
import sys
from math import pi
import cairo 
import clutter
from clutter import cogl


class ODDSBODKINS (clutter.Actor):
	__gtype_name__ = 'ODDSBODKINS'

	def __init__ (self):
		clutter.Actor.__init__(self)
	def do_paint(self):
		c=clutter.color_from_string('White')
		self.cogl_path(c)
	def cogl_path(self, color):
		cogl.set_source_color( color )

		cogl.path_move_to(0,0)
		cogl.path_rel_curve_to(10,10,10,10,100,100)
		cogl.path_stroke()
		
class ShapePath (clutter.CairoTexture):
	__gtype_name__ = 'ShapePath'

	def __init__ (self, width, height):
		clutter.CairoTexture.__init__(self, width=width, height=height)
		self._cairo_draw()

	def _cairo_draw(self, thickness=2):
		context = self.cairo_create()
		context.set_line_width(thickness)

		context.set_source_color(clutter.Color(255, 0, 0, 0x88))
		context.move_to(0,0)
		context.rel_curve_to(10,10,10,10,100,100)
		context.stroke()

## Is the below not covered by __gtype_name__ in class?
#gobject.type_register(ShapePath)

if __name__ == '__main__':
	stage = clutter.Stage()
	stage.set_size(640, 480)
	stage.set_color(clutter.color_from_string('Black'))
	stage.connect('destroy', clutter.main_quit)

	# Either block on its own is ok.
	# Both cause a segfault.

	block2=True
	block1=False#True

	# Block 1
	if block1:
		shapepath = ShapePath(200,200)
		shapepath.set_position(320, 240)
		stage.add(shapepath)
		shapepath.show()

	# Block 2 
	if block2:
		ca=ODDSBODKINS()
		ca.set_position(100,240)
		stage.add(ca)
		ca.show()

	stage.show()
	clutter.main()

	sys.exit(0)

Reply via email to