Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-16318

Wrong positioning of repeatedly created movable items.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • Some future release
    • 4.7.1, 5.5.0, 6.4.0
    • Widgets: GraphicsView
    • 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.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            bibr Andreas Aardal Hanssen
            deruhu Michael
            Votes:
            4 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes