PDA

View Full Version : QGraphicsScene qt_metacall problem



pratham_shah
14th March 2012, 13:42
Hi,
I am facing an issue when, in QGraphicsScene using BSPItemIndex method, I try and delete a QGraphicsItem at some specific positions only.
The application simply crashes and when tried debugging goes to QGraphicsScene::qt_metacall(..).

If I change the ItemIndexMethod to NoIndex the application works correctly.

The application requires a large dynamic scene, hence using NoIndex makes the application considerably slow.
Is changing the ItemIndexMethod run-time advisable ?
Please provide some pointers to the issue.

Spitfire
16th March 2012, 14:41
Try removing the item from the scene first before deleting it.

Turning indexing off and then back on is fairly expensive so I would avoid that for large scenes.

wysota
16th March 2012, 15:40
Don't delete items as a response to signals or events that carry that item as a parameter. Hide the item and schedule a deletion at a later point in time.

pratham_shah
19th March 2012, 04:22
I have already delete the item from the scene before deleting. Also there is no event or signal which is accepting item as parameter where i am deleting the item.

The application has a graph like structure, so deleting a node also results in deletion of an edge. so removing both the items from the scene I instantiate its deletion.
Also the problem is not reproducible every time. Only for a specific node, at a specific position and graph layout this problem occurs.
To give you an idea deleting a node result in following process:
1. Find the boundingRect() of the node and check the intersecting items for the bounding rect of type edge.
2. Check if the egde is really connected to the node.
3. If yes, remove the edge from the scene and instantiate deletion of the edge and the node from the graph.

ChrisW67
19th March 2012, 06:02
Seems an odd design. Why not have the modes keep a list of the edges they are connected to, and the edges the end nodes they connect to? Like the Diagram Scene Example.

Spitfire
19th March 2012, 09:08
I think that wihout showing us the offending code we can't help you much.

Or you could create minimal compilable example of the issue.