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/qquickcontrol.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/qquickcontrol.cpp')
-rw-r--r-- | src/quicktemplates2/qquickcontrol.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp index cfecc67c..6fbd4c07 100644 --- a/src/quicktemplates2/qquickcontrol.cpp +++ b/src/quicktemplates2/qquickcontrol.cpp @@ -292,6 +292,9 @@ void QQuickControlPrivate::setContentItem_helper(QQuickItem *item, bool notify) if (contentItem == item) return; + if (!contentItem.isExecuting()) + cancelContentItem(); + q->contentItemChange(item, contentItem); delete contentItem; contentItem = item; @@ -938,13 +941,19 @@ QLocale QQuickControlPrivate::calcLocale(const QQuickItem *item) static inline QString contentItemName() { return QStringLiteral("contentItem"); } +void QQuickControlPrivate::cancelContentItem() +{ + Q_Q(QQuickControl); + quickCancelDeferred(q, contentItemName()); +} + void QQuickControlPrivate::executeContentItem(bool complete) { Q_Q(QQuickControl); if (contentItem.wasExecuted()) return; - if (!contentItem) + if (!contentItem || complete) quickBeginDeferred(q, contentItemName(), contentItem); if (complete) quickCompleteDeferred(q, contentItemName(), contentItem); @@ -952,13 +961,19 @@ void QQuickControlPrivate::executeContentItem(bool complete) static inline QString backgroundName() { return QStringLiteral("background"); } +void QQuickControlPrivate::cancelBackground() +{ + Q_Q(QQuickControl); + quickCancelDeferred(q, backgroundName()); +} + void QQuickControlPrivate::executeBackground(bool complete) { Q_Q(QQuickControl); if (background.wasExecuted()) return; - if (!background) + if (!background || complete) quickBeginDeferred(q, backgroundName(), background); if (complete) quickCompleteDeferred(q, backgroundName(), background); @@ -1257,6 +1272,9 @@ void QQuickControl::setBackground(QQuickItem *background) if (d->background == background) return; + if (!d->background.isExecuting()) + d->cancelBackground(); + delete d->background; d->background = background; if (background) { |