diff options
author | Liang Qi <liang.qi@qt.io> | 2017-05-31 08:13:14 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-05-31 08:13:14 +0200 |
commit | 1e472c6c1aafd893eebf29929b36b77c42c0e199 (patch) | |
tree | 5d63cff70bc21e0ead4135347cc87e65e864f824 /src/quicktemplates2 | |
parent | 44dd55be23138f0a6495b08818acaaa0ff68b086 (diff) | |
parent | ef6b8d3081f0bf93d6d59e67c8e3f82c63c511c3 (diff) |
Merge remote-tracking branch 'origin/5.9.0' into 5.9
Change-Id: Iba044084bf82f6b2b8ceba4aa2a80bdcf8fc38e0
Diffstat (limited to 'src/quicktemplates2')
-rw-r--r-- | src/quicktemplates2/qquickcombobox.cpp | 10 | ||||
-rw-r--r-- | src/quicktemplates2/qquickdrawer.cpp | 7 | ||||
-rw-r--r-- | src/quicktemplates2/qquickoverlay.cpp | 29 | ||||
-rw-r--r-- | src/quicktemplates2/qquickoverlay_p_p.h | 2 | ||||
-rw-r--r-- | src/quicktemplates2/qquickpopup.cpp | 2 |
5 files changed, 32 insertions, 18 deletions
diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index 04ab559f..d987182c 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -672,7 +672,15 @@ QQuickComboBox::QQuickComboBox(QQuickItem *parent) QQuickComboBox::~QQuickComboBox() { - setPopup(nullptr); + Q_D(QQuickComboBox); + // Disconnect visibleChanged() to avoid a spurious highlightedIndexChanged() signal + // emission during the destruction of the (visible) popup. (QTBUG-57650) + QObjectPrivate::disconnect(d->popup, &QQuickPopup::visibleChanged, d, &QQuickComboBoxPrivate::popupVisibleChanged); + + // Delete the popup directly instead of calling setPopup(nullptr) to avoid calling + // destroyDelegate(popup) and potentially accessing a destroyed QML context. (QTBUG-50992) + delete d->popup; + d->popup = nullptr; } /*! diff --git a/src/quicktemplates2/qquickdrawer.cpp b/src/quicktemplates2/qquickdrawer.cpp index 030fc98e..8159f05e 100644 --- a/src/quicktemplates2/qquickdrawer.cpp +++ b/src/quicktemplates2/qquickdrawer.cpp @@ -301,7 +301,7 @@ bool QQuickDrawerPrivate::grabMouse(QQuickItem *item, QMouseEvent *event) Q_Q(QQuickDrawer); handleMouseEvent(item, event); - if (!window || !interactive || popupItem->keepMouseGrab()) + if (!window || !interactive || popupItem->keepMouseGrab() || popupItem->keepTouchGrab()) return false; const QPointF movePoint = event->windowPos(); @@ -377,6 +377,7 @@ bool QQuickDrawerPrivate::grabTouch(QQuickItem *item, QTouchEvent *event) } if (overThreshold) { + popupItem->grabTouchPoints(QVector<int>() << touchId); popupItem->setKeepTouchGrab(true); offset = offsetAt(movePoint); } @@ -422,7 +423,6 @@ bool QQuickDrawerPrivate::handleRelease(QQuickItem *item, const QPointF &point, return QQuickPopupPrivate::handleRelease(item, point, timestamp); } - pressPoint = QPointF(); velocityCalculator.stopMeasuring(point, timestamp); qreal velocity = 0; @@ -479,6 +479,9 @@ bool QQuickDrawerPrivate::handleRelease(QQuickItem *item, const QPointF &point, popupItem->setKeepMouseGrab(false); popupItem->setKeepTouchGrab(false); + pressPoint = QPointF(); + touchId = -1; + return wasGrabbed; } diff --git a/src/quicktemplates2/qquickoverlay.cpp b/src/quicktemplates2/qquickoverlay.cpp index 0f7edc77..15104808 100644 --- a/src/quicktemplates2/qquickoverlay.cpp +++ b/src/quicktemplates2/qquickoverlay.cpp @@ -181,11 +181,23 @@ QQuickOverlayPrivate::QQuickOverlayPrivate() { } -bool QQuickOverlayPrivate::startDrag(QEvent *event) +bool QQuickOverlayPrivate::startDrag(QEvent *event, const QPointF &pos) { + Q_Q(QQuickOverlay); if (allDrawers.isEmpty()) return false; + // don't start dragging a drawer if a modal popup overlay is blocking (QTBUG-60602) + QQuickItem *item = q->childAt(pos.x(), pos.y()); + if (item) { + const auto popups = stackingOrderPopups(); + for (QQuickPopup *popup : popups) { + QQuickPopupPrivate *p = QQuickPopupPrivate::get(popup); + if (p->dimmer == item && popup->isVisible() && popup->isModal()) + return false; + } + } + const QVector<QQuickDrawer *> drawers = stackingOrderDrawers(); for (QQuickDrawer *drawer : drawers) { QQuickDrawerPrivate *p = QQuickDrawerPrivate::get(drawer); @@ -251,7 +263,7 @@ bool QQuickOverlayPrivate::handleMouseEvent(QQuickItem *source, QMouseEvent *eve { switch (event->type()) { case QEvent::MouseButtonPress: - if (!target && startDrag(event)) + if (!target && startDrag(event, event->windowPos())) return true; return handlePress(source, event, target); case QEvent::MouseMove: @@ -269,17 +281,12 @@ bool QQuickOverlayPrivate::handleTouchEvent(QQuickItem *source, QTouchEvent *eve bool handled = false; switch (event->type()) { case QEvent::TouchBegin: - if (!target && startDrag(event)) - handled = true; - else - handled = handlePress(source, event, target); - break; - case QEvent::TouchUpdate: + case QEvent::TouchEnd: for (const QTouchEvent::TouchPoint &point : event->touchPoints()) { switch (point.state()) { case Qt::TouchPointPressed: - if (!target && startDrag(event)) + if (!target && startDrag(event, point.scenePos())) handled = true; else handled |= handlePress(source, event, target); @@ -296,10 +303,6 @@ bool QQuickOverlayPrivate::handleTouchEvent(QQuickItem *source, QTouchEvent *eve } break; - case QEvent::TouchEnd: - handled = handleRelease(source, event, target ? target : mouseGrabberPopup.data()); - break; - default: break; } diff --git a/src/quicktemplates2/qquickoverlay_p_p.h b/src/quicktemplates2/qquickoverlay_p_p.h index fa53d52b..5553bda8 100644 --- a/src/quicktemplates2/qquickoverlay_p_p.h +++ b/src/quicktemplates2/qquickoverlay_p_p.h @@ -70,7 +70,7 @@ public: return overlay->d_func(); } - bool startDrag(QEvent *event); + bool startDrag(QEvent *event, const QPointF &pos); bool handlePress(QQuickItem *source, QEvent *event, QQuickPopup *target); bool handleMove(QQuickItem *source, QEvent *event, QQuickPopup *target); bool handleRelease(QQuickItem *source, QEvent *event, QQuickPopup *target); diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp index 406c513f..59a9a6dc 100644 --- a/src/quicktemplates2/qquickpopup.cpp +++ b/src/quicktemplates2/qquickpopup.cpp @@ -304,7 +304,7 @@ bool QQuickPopupPrivate::acceptTouch(const QTouchEvent::TouchPoint &point) if (point.id() == touchId) return true; - if (touchId == -1 && point.state() == Qt::TouchPointPressed) { + if (touchId == -1 && point.state() != Qt::TouchPointReleased) { touchId = point.id(); return true; } |