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

protect against nested mouse events deleted after deleting a QObject on OS X

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • Not Evaluated
    • None
    • 4.8.6, 4.8.7
    • QPA
    • None
    • OS X 10.6.8 and 10.9.5, Qt 4.8.6 (MacPorts), KDE 4.14.4
    • macOS

    Description

      Qt applications on OS X can delete an object inheriting QWidget (or QObject) in a context where events are still pending for that object, or where the process of deleting the object generates events. This has proved to be extremely hard to debug because the object that receives the event is not necessarily an object that was allocated (and deleted) in user code.

      Analysing crash backtraces I found the following comment in qt_mac_handleMouseEvent (line 1280):

          if (eventType == QEvent::MouseButtonRelease) {
              // A mouse button was released, which means that the implicit grab was
              // released. We therefore need to re-check if should send (delayed) enter leave events:
              // qt_button_down has now become NULL since the call at the top of the function. Also, since
              // the relase might have closed a window, we dont give the nativeWidget hint
              qt_mac_getTargetForMouseEvent(0, QEvent::None, localPoint, globalPoint, nativeWidget, &widgetUnderMouse);
      

      Indeed, the crash occurs in qt_mac_getTargetForMouseEvent(), when trying to access nativeWidget->isVisible() (line 1069).

      The comment seems to indicate that qt_mac_getTargetForMouseEvent should be invoked with a NULL pointer instead of the possibly stale contents of nativeWidget.

      Attached is a patch that modifies the function to do just that, and since running Qt4 with this modification I haven't had this particular crash anymore.

      Attachments

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

        Activity

          People

            sorvig Morten Sørvig
            rjvbertin René Bertin
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes