Details
-
Bug
-
Resolution: Won't Do
-
Not Evaluated
-
None
-
4.8.6, 4.8.7
-
None
-
OS X 10.6.8 and 10.9.5, Qt 4.8.6 (MacPorts), KDE 4.14.4
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.