Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
4.6.0
-
None
-
Windows XP 32-bit Qt 4.6.0
-
b6b1dee9460d6fdde0b8ad005301c0a315ad30bf
Description
When setting a parent item for a item there seems to be a case where a crash can occur. When setParentItem() is called the item is added to the scene of the parent. If the new child item wants to become active (wantsActive), then QGraphicsScene() ends up calling items() in setActivePanel() to get all items, which in turn sorts the scene's items. This causes an issue because the depth of the new child item has not been updated yet. It is only updated at the end of the setParentHelper() method. This causes an crash in qt_closestItemFirst() because there is an assumption that the depth value is valid. I have attached a stack trace and a patch that seems to fix the problem by checking both parent values against NULL for both items. I hope to try to find time to come up with a simple reproducable test case soon.
It is also worth noting that this is only an issue when the depth of an item is changing. In my example I am dragging a top level item onto another item in the scene.As a temporary work around I am calling setActive(False) before setting the parent.