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

Mac OSX [CRASH] crash when hiding/destroying a widget the mouse is over

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2: Important P2: Important
    • None
    • 4.5.0, 4.5.1, 4.5.2, 4.5.3
    • None
    • macOS

      Bug was reported already at the old Task tracker and has Id
      256731 - crash problem in QWidgetPrivate::hide_sys (qwidget_mac.mm)

      I repeat it here as we did not get any response for that.

      We get a crash problem when hiding/closing widgets in a certain order on Mac OSX.

      Compile and run the attached small sample program.
      click ASAP in the middle of the app and wait until the QLineEdit field was destroyed.
      After that move the mouse a bit -> crash.

      Explanation: Calling QWidget::hide crashes because of an invalid "qt_mouseover" variable defined as
      extern QPointer<QWidget> qt_mouseover; //qapplication_mac.mm:line 190

      qt_mouseover is set in the QWidget::hide_sys function as a result of QApplication::widgetAt(QCursor::pos());

      The problem occurs when the mouse is over a widget when we call 'hide' . A previous call to hide_sys executes the QWidget::destroy code (the mouse is over a widget which is half dead) twice.

      That means that QObjectPrivate::clearGuards has been already called for that particular widget and qt_mouseover holds an invalid pointer.

      The next call to hide_sys tries to do something with qt_mouseover in dispatchEnterLeave and crashes.

      The developer thought that the QPointer solves the problem of potential invalid widgets however the internal usage turned this into a trap.

      The fix is to reset qt_mouseover in QWidget::destroy.

      We use the fix internally already some months without problems (1200 automatic test cases daily)attached in the patch.

        1. qt4hidecrash.zip
          2 kB
          Leo Schubert
        2. 256731.patch
          0.5 kB
          Leo Schubert
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            hanssen Andreas Aardal Hanssen (closed Nokia identity) (Inactive)
            ls@4js.com Leo Schubert
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes