iOS: only flush non-user input events from layoutSubviews

Change a4e1c15b1 will cause setGeometry to take immediate effect
by doing a synchronuous layout and a flush. As a side-effect, the
flush will also send posted touch events. So if the current
setGeometry call comes from a touchMove, a touchEnd might
be delivered before the touchMove returns.

A crash in QToolBar drag-n-drop is seen from this. There
drag data is deleted on mouse release (during the flush), while
a mouse move is already handled on the stack. When the code returns
to the move handler, drag-data has been deleted, and we have a crash.

Since the root problem is that we flush events on a callback from
the app, we can be more careful and precise by only flushing non-user
input events from layoutSubviews.

Change-Id: I3f5e025d774d21509ef837de9d7e85a1ac6e48cc
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
bb10
Richard Moe Gustavsen 2015-02-13 12:30:33 +01:00
parent a945124a42
commit 6342c4a183
1 changed files with 3 additions and 2 deletions

View File

@ -146,8 +146,9 @@
QRect previousGeometry = requestedGeometry != actualGeometry ?
requestedGeometry : qt_window_private(m_qioswindow->window())->geometry;
QWindowSystemInterface::handleGeometryChange(m_qioswindow->window(), actualGeometry, previousGeometry);
QWindowSystemInterface::flushWindowSystemEvents();
QWindow *window = m_qioswindow->window();
QWindowSystemInterface::handleGeometryChange(window, actualGeometry, previousGeometry);
QWindowSystemInterface::flushWindowSystemEvents(window->inherits("QWidgetWindow") ? QEventLoop::ExcludeUserInputEvents : QEventLoop::AllEvents);
if (actualGeometry.size() != previousGeometry.size()) {
// Trigger expose event on resize