[Interest] Qt 4.8 qt_mac_handleMouseEvent() question (crash-related)

René J.V. Bertin rjvbertin at gmail.com
Fri Jan 16 21:41:50 CET 2015


Hello,

Hopefully this kind of topic isn't too much out of place on this list:

I keep seeing crashes on OS X that I think are related to some QObject child being deleted instead of release through deleteLater(), ultimately leading to the delivery of a pending event to that object and then an access to some internal object that is no longer valid.
SPecifically, this happens about once every 3-5 times when closing KDevelop's patch review plugin without having closed all documents open in it manually first.

I have already moved a number of KDevelop object from delete to deleteLater, but can only make more or less educated guesses which object(s) is/are involved.

Now that I have more precise information where the crash occurs I have a question about the meaning of a comment in Qt code:

    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);
        qt_mac_checkEnterLeaveForNativeWidgets(widgetUnderMouse);
    }

the crash occurs in qt_mac_getTargetForMouseEvent(), and can only be when it attempts to call nativeWidget->isVisible() .

But doesn't in this case the statement "we dont give the nativeWidget hint" mean that a null pointer should be passed instead of a potentially stale pointer to a former nativeWidget?

BR,
R.B.



More information about the Interest mailing list