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

Deleting a gesture target QGraphicsObject during a gesture sequence will cause a crash in graphics scene

    XMLWordPrintable

Details

    • 734ba1f540aaedc4a3558268bd7350c0b15325a4

    Description

      If a QGraphicsObject which is a recipient of gesture events gets deleted during a gesture sequence (it has accepted GestureStarted but gets deleted before GestureFinished or GestureCanceled) there will be a crash ("The inferior stopped because it received a signal from the Operating System. Signal name: SIGSEGV, Signal meaning: Segmentation fault") in qgraphicsitem.cpp:

      /*!
        \since 4.6
      
        Return the graphics item cast to a QGraphicsObject, if the class is actually a
        graphics object, 0 otherwise.
      */
      QGraphicsObject *QGraphicsItem::toGraphicsObject()
      {
          return d_ptr->isObject ? static_cast<QGraphicsObject *>(this) : 0;   // <-- crashes because d_ptr is a null pointer
      }
      

      Apparently the gesture event dispatching system doesn't take into account that the target may not exist anymore.

      NOTE ON THE AUTOTEST:

      I was unable to reproduce the exact same crash with the autotest using QTest::touchEvent. The test will nonetheless crash albeit the crash is not the one described above. I was able to reproduce the exact same crash with the autotest when running it on Qt Creator if I inserted a breakpoint somewhere in the gesture event handling function (try line 96 for example). Therefore I have also included a manual test where you can reproduce the crash described above. To do this, press and move within the inner rectangle of the test program.

      Attachments

        Issue Links

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

          Activity

            People

              dzyubenk Denis Dzyubenko (Inactive)
              jaakkorp Jaakko Korpela
              Votes:
              4 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes