[Qt-jambi-interest] Overriding itemChange() crashes the VM in 4.4.0_01

Mika Halttunen mika.halttunen at gmail.com
Tue Jul 8 10:35:20 CEST 2008


Hi,
this is probably related to 
http://trolltech.com/developer/task-tracker/index_html?method=entry&id=215908, 
but I though I'd give additional information about this.

I have VertexItems (based on QGraphicsItem) and PolygonItems (based on 
QGraphicsPolygonItem). PolygonItems should have VertexItems as children, 
so when I move a polygon it's vertices would also move.

I'm setting up the PolygonItem from my own Polygon class like this:

public void setMyPolygon(Polygon poly) {
	this.polygon = poly;
	this.color = new QColor(poly.getColor().getRed(), 
poly.getColor().getGreen(), poly.getColor().getBlue(), 
poly.getColor().getAlpha());

	setBrush(new QBrush(color));
	setPen(VertexItem.blackPen);

	// Create the Qt polygon
	QPolygonF qPoly = new QPolygonF();
	// Add the vertices
	for (Vertex v : poly.getVertices()) {
		qPoly.add(v.position.x, v.position.y);

		// Add them as children VertexItems
		VertexItem vItem = new VertexItem(v);
		vItem.setParentItem(this); ///// <--- CRASHES HERE!
	}

	setPolygon(qPoly);
}

The line vItem.setParentItem(this) causes the crash. That occurs only
when either VertexItem and/or PolygonItem have overridden itemChange().

Even when I just supply the default implementation, it will crash. For 
example, on VertexItem:

@Override
public Object itemChange(GraphicsItemChange change, Object value) {
	return super.itemChange(change, value);
}


So the bottom line is, itemChange() can be overridden when the items are 
not in any kind of parent/child relationship.

Unfortunately, I cannot continue my project too far without this being 
fixed. :( Hopefully you get it resolved for the next Qt Jambi update. Is 
there any work arounds for this? I'd really need to know when the 
Vertex/Polygon item positions change..

Anyways, thanks for the great work on Qt + Qt Jambi! :)

--
Mika



More information about the Qt-jambi-interest mailing list