diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-12-19 13:38:40 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-12-21 14:46:30 +0000 |
commit | c40486acc352d49398186fa32d1ccabdd5fc83c6 (patch) | |
tree | b4f77d072020eef0bb17d4491e98daa1a048537a /src/quicktemplates2/qquickdial.cpp | |
parent | 1e33020fc02b56001d805d3d66badd41480b746d (diff) |
Fix deferred execution
If the QML engine refuses to defer execution of a delegate (it contains
an ID), we must make sure to cancel any pending deferred execution for
the same delegate. Otherwise, we may end up overriding a custom (non-
deferred) delegate with a default (deferred) delegate.
This patch adds a new test style "identified" to tst_customization.
This style contains delegates with IDs so we can test the behavior with
IDs in base styles. Furthermore, overriding delegates is now tested
in various ways (with and without IDs in the base and custom styles) in
a separate test method. This is done by generating QML code to override
delegates with dummy Item instances with appropriate IDs and names.
Task-number: QTBUG-65341
Change-Id: Ie6dca287cb74672004d9d8f599760b9d32c3a380
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickdial.cpp')
-rw-r--r-- | src/quicktemplates2/qquickdial.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/quicktemplates2/qquickdial.cpp b/src/quicktemplates2/qquickdial.cpp index 964cefe1..b5957069 100644 --- a/src/quicktemplates2/qquickdial.cpp +++ b/src/quicktemplates2/qquickdial.cpp @@ -123,6 +123,7 @@ public: void handleRelease(const QPointF &point) override; void handleUngrab() override; + void cancelHandle(); void executeHandle(bool complete = false); qreal from; @@ -258,13 +259,19 @@ void QQuickDialPrivate::handleUngrab() static inline QString handleName() { return QStringLiteral("handle"); } +void QQuickDialPrivate::cancelHandle() +{ + Q_Q(QQuickDial); + quickCancelDeferred(q, handleName()); +} + void QQuickDialPrivate::executeHandle(bool complete) { Q_Q(QQuickDial); if (handle.wasExecuted()) return; - if (!handle) + if (!handle || complete) quickBeginDeferred(q, handleName(), handle); if (complete) quickCompleteDeferred(q, handleName(), handle); @@ -553,6 +560,9 @@ void QQuickDial::setHandle(QQuickItem *handle) if (handle == d->handle) return; + if (!d->handle.isExecuting()) + d->cancelHandle(); + delete d->handle; d->handle = handle; if (d->handle && !d->handle->parentItem()) |