summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@qt.io>2016-10-05 16:51:04 +0200
committerPaolo Angelelli <paolo.angelelli@qt.io>2016-10-05 15:44:24 +0000
commitbfba4efe54e838fe9ac48a85db314743680f576f (patch)
treebe2aa9a0b8d3971a1f9843b4c3851d848de65596
parent218e208bbf1c3112d2ea5781debc605fc76db80a (diff)
downloadqtlocation-bfba4efe54e838fe9ac48a85db314743680f576f.tar.gz
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>
-rw-r--r--src/imports/location/qdeclarativegeomapitembase.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/imports/location/qdeclarativegeomapitembase.cpp b/src/imports/location/qdeclarativegeomapitembase.cpp
index 8e825f5b..1788f740 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;
}
/*!