Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
4.7.1, 5.5.0, 6.4.0
-
None
-
Debian testing amd64
Description
When I create a single movable item and start manipulate it with mouse, everything works correctly. When I destroy this item and creaste an object of this type again at first attempt to move it the item is thrown to lower left corner of the graphic scene and the movement occurs there instead of where the mouse cursor is. After investigation of the code (4.7.1) I have found the following: when graphic item is deleted its initial position is not removed from the QGraphicsScens's movingItemsInitialPositions map. So the map remains non-empty. In this case the entry for the newly created item is not added to the map (see qgraphicsitem.cpp lines 7098 - 7100) and when the map is queried for this item below (without check whether an entry for this item exists) a 0,0 position is retirned. I fixed the problem by adding the following lines after line 7101:
else if (!initialPositions.contains(this))
initialPositions[this] = pos();
but this is a palliative only, since entries for non-existent (deleted) items will be accumulating in movingItemsInitialPositions map. It seems a fix should be applied in QGraphicsItem destructor instead.