macOS: Bail out early in case a popup is closed by a mouseDown

It can happen that AppKit calls -mouseDown: on a popup's view, but
we consider the click to be outside of popup's area (happens on the
1-pixel edge of a 'geometry', QRect::contains() returns false).
If we send close event to essentially 'self', m_platformWindow
is becoming nullptr. So we bail out early, no further processing
is needed.

Fixes: QTBUG-77348
Change-Id: I224943e6bcf4ae052412ef7dc7b23a94f999aa19
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Timur Pocheptsov 2019-08-19 15:04:42 +02:00 committed by Tor Arne Vestbø
parent 70e7445dbe
commit fc04905281

View File

@ -389,14 +389,16 @@
}
// Close the popups if the click was outside.
if (!inside) {
bool selfClosed = false;
Qt::WindowType type = QCocoaIntegration::instance()->activePopupWindow()->window()->type();
while (QCocoaWindow *popup = QCocoaIntegration::instance()->popPopupWindow()) {
selfClosed = self == popup->view();
QWindowSystemInterface::handleCloseEvent(popup->window());
QWindowSystemInterface::flushWindowSystemEvents();
}
// Consume the mouse event when closing the popup, except for tool tips
// were it's expected that the event is processed normally.
if (type != Qt::ToolTip)
if (type != Qt::ToolTip || selfClosed)
return;
}
}