Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.4.1, 5.5.1
-
cf59a0acaee9b47bd371dd3ab8f0a6bd1f5b6d35
Description
Attached is a reduction of a crash bug I discovered in my company's app.
Reproduced: Qt 5.4.1, MacOS 10.10 and Win 8.1
Steps:
1) run the attached QML app
2) scroll down in the grid so element "1" is offscreen
3) click on an element
Expected: grid scrolls to the top so "1" is visible
Observed: crash with the stack below
- no crash if propagateComposedEvents = false (we set it to true to workaround a drag issue)
- no crash if there is just one MouseArea in the delegate (we have two because – unlike the attached example – one is in a superclass and the other is in a subclass)
- no crash if the scrolling happens in onPressed instead of onReleased
- no crash if I use "list.currentY = 0" instead of positionViewAtIndex(), not sure why...
- The crash occurs in the same way if I replace GridView with ListView
- no crash if I delay the scroll to happen after the onReleased
I caught this in the debugger and discovered that "window" is null in the following function in qquickmousearea.cpp. I believe the root cause is that the MouseArea has already been detached from the GUI but not yet destroyed when the callback is invoked. I believe a simple null check will solve the bug. Alternatively, perhaps the MouseArea should be detached from the mouse callback chain when its window reference is nulled.
void QQuickMouseAreaPrivate::propagate(QQuickMouseEvent* event, PropagateType t) { Q_Q(QQuickMouseArea); if (!propagateComposedEvents) return; QPointF scenePos = q->mapToScene(QPointF(event->x(), event->y())); propagateHelper(event, window->contentItem(), scenePos, t); }
Crash stack on Mac (nearly identical on Windows, but Windows shows the intervening tail call to propagate() which is elided in the Mac stack, I think because I'm running a debug build of Qt on Win and a release build of Qt on Mac)
0 org.qt-project.QtQuick 0x0000000104777e14 QQuickWindow::contentItem() const + 4
1 org.qt-project.QtQuick 0x00000001047ea069 QQuickMouseArea::setPressed(Qt::MouseButton, bool) + 601
2 org.qt-project.QtQuick 0x00000001047ea825 QQuickMouseArea::mouseReleaseEvent(QMouseEvent*) + 149
3 org.qt-project.QtQuick 0x00000001047698f9 QQuickItem::event(QEvent*) + 297
4 org.qt-project.QtWidgets 0x0000000105ccc64b QApplicationPrivate::notify_helper(QObject*, QEvent*) + 251
5 org.qt-project.QtWidgets 0x0000000105ccf9a0 QApplication::notify(QObject*, QEvent*) + 8192
6 org.qt-project.QtCore 0x00000001052d8de3 QCoreApplication::notifyInternal(QObject*, QEvent*) + 115
7 org.qt-project.QtQuick 0x0000000104774f27 QQuickWindow::sendEvent(QQuickItem*, QEvent*) + 167
8 org.qt-project.QtQuick 0x000000010477989a QQuickWindowPrivate::deliverMouseEvent(QMouseEvent*) + 234
9 org.qt-project.QtQuick 0x0000000104779d90 QQuickWindow::mouseReleaseEvent(QMouseEvent*) + 560
10 org.qt-project.QtQuick 0x0000000104820267 QQuickView::mouseReleaseEvent(QMouseEvent*) + 135
11 org.qt-project.QtGui 0x0000000104b201e1 QWindow::event(QEvent*) + 513
12 org.qt-project.QtQuick 0x0000000104778164 QQuickWindow::event(QEvent*) + 468
13 org.qt-project.QtWidgets 0x0000000105ccc64b QApplicationPrivate::notify_helper(QObject*, QEvent*) + 251
14 org.qt-project.QtWidgets 0x0000000105ccf9a0 QApplication::notify(QObject*, QEvent*) + 8192
15 org.qt-project.QtCore 0x00000001052d8de3 QCoreApplication::notifyInternal(QObject*, QEvent*) + 115
16 org.qt-project.QtGui 0x0000000104b13d3d QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent*) + 2189
17 org.qt-project.QtGui 0x0000000104b12bd3 QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent*) + 131
18 org.qt-project.QtGui 0x0000000104b0051a QWindowSystemInterface::sendWindowSystemEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 346
19 libqcocoa.dylib 0x00000001095bca41 QCocoaEventDispatcherPrivate::postedEventsSourceCallback(void*) + 33
Attachments
For Gerrit Dashboard: QTBUG-49100 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
142118,2 | MouseArea: fixed a crash in propagate() | 5.5 | qt/qtdeclarative | Status: MERGED | +2 | 0 |