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

Releasing QQuickItemGrabResult before ready signal was sent can lead to crashes

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P1: Critical P1: Critical
    • None
    • 6.8.3
    • Quick: Other
    • None
    • Windows

      When you call grabToImage() on a QQuickItem you get back a QSharedPointer<QQuickItemGrabResult>

      The QQuickItemGrabResult contains a QImage where the documentation states this:

      If the grab is not yet complete or if it failed, a null image is returned (image.isNull() will return true).

      If you check for isNull and release the QSharedPointer if its no longer false then it can happen that this leads to a crash. There seems to be a race condition where an QEvent is about to be posted but the release of the QSharedPointer destroys the event source

      I attached a minimal example that shows this effect. It doesn't crash always when the QSharedPointer is released at the wrong time. But it happens after some time. 

      When the timer in the example is set to 0 it crashes almost immediately.

      It also seems to happen only if VSync is disabled

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

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            scheungrab@cipsoft.com Anton Scheungrab
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes