From bfba4efe54e838fe9ac48a85db314743680f576f Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn <frederik.gladhorn@qt.io> Date: Wed, 5 Oct 2016 16:51:04 +0200 Subject: [PATCH] QDeclarativeGeoMapItemBase::childMouseEventFilter: Do not eat release events The filter can lead to events outside of the item being "dismissed" or rather sent the the map item. When testing with MapRects, when dragging a map rect fast, I would sometimes get release events outside of the map rect, which would then end up being deliverd to the QDeclarativeGeopMapItemBase subclass. This effectively prevents MouseAreas inside of the GeoMapItem from receiving their release event. That in turn breaks follow up events to said items. While I still consider this extremely evil and bad behavior, at least this doesn't completely break event delivery any more. Change-Id: I228d64e04140e2434779d07d8f03a8e9f2d11f83 Reviewed-by: Paolo Angelelli <paolo.angelelli@qt.io> --- .../location/qdeclarativegeomapitembase.cpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/imports/location/qdeclarativegeomapitembase.cpp b/src/imports/location/qdeclarativegeomapitembase.cpp index 8e825f5b4..1788f7406 100644 --- a/src/imports/location/qdeclarativegeomapitembase.cpp +++ b/src/imports/location/qdeclarativegeomapitembase.cpp @@ -198,18 +198,14 @@ float QDeclarativeGeoMapItemBase::zoomLevelOpacity() const bool QDeclarativeGeoMapItemBase::childMouseEventFilter(QQuickItem *item, QEvent *event) { Q_UNUSED(item) - switch (event->type()) { - case QEvent::MouseButtonPress: - case QEvent::MouseButtonRelease: - if (contains(static_cast<QMouseEvent*>(event)->pos())) { - return false; - } else { - event->setAccepted(false); - return true; - } - default: - return false; + if (event->type() == QEvent::MouseButtonPress && !contains(static_cast<QMouseEvent*>(event)->pos())) { + // This is an evil hack: in case of items that are not rectangles, we never accept the event. + // Instead the events are now delivered to QDeclarativeGeoMapItemBase which doesn't to anything with them. + // The map below it still works since it filters events and steals the events at some point. + event->setAccepted(false); + return true; } + return false; } /*! -- GitLab