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/qquickcombobox.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/qquickcombobox.cpp')
-rw-r--r-- | src/quicktemplates2/qquickcombobox.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index d221b9bc..fb10730e 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -253,7 +253,10 @@ public: void handleRelease(const QPointF &point) override; void handleUngrab() override; + void cancelIndicator(); void executeIndicator(bool complete = false); + + void cancelPopup(); void executePopup(bool complete = false); bool flat; @@ -671,13 +674,19 @@ void QQuickComboBoxPrivate::handleUngrab() static inline QString indicatorName() { return QStringLiteral("indicator"); } +void QQuickComboBoxPrivate::cancelIndicator() +{ + Q_Q(QQuickComboBox); + quickCancelDeferred(q, indicatorName()); +} + void QQuickComboBoxPrivate::executeIndicator(bool complete) { Q_Q(QQuickComboBox); if (indicator.wasExecuted()) return; - if (!indicator) + if (!indicator || complete) quickBeginDeferred(q, indicatorName(), indicator); if (complete) quickCompleteDeferred(q, indicatorName(), indicator); @@ -685,13 +694,19 @@ void QQuickComboBoxPrivate::executeIndicator(bool complete) static inline QString popupName() { return QStringLiteral("popup"); } +void QQuickComboBoxPrivate::cancelPopup() +{ + Q_Q(QQuickComboBox); + quickCancelDeferred(q, popupName()); +} + void QQuickComboBoxPrivate::executePopup(bool complete) { Q_Q(QQuickComboBox); if (popup.wasExecuted()) return; - if (!popup) + if (!popup || complete) quickBeginDeferred(q, popupName(), popup); if (complete) quickCompleteDeferred(q, popupName(), popup); @@ -1015,6 +1030,9 @@ void QQuickComboBox::setIndicator(QQuickItem *indicator) if (d->indicator == indicator) return; + if (!d->indicator.isExecuting()) + d->cancelIndicator(); + delete d->indicator; d->indicator = indicator; if (indicator) { @@ -1052,6 +1070,9 @@ void QQuickComboBox::setPopup(QQuickPopup *popup) if (d->popup == popup) return; + if (!d->popup.isExecuting()) + d->cancelPopup(); + if (d->popup) { QObjectPrivate::disconnect(d->popup.data(), &QQuickPopup::visibleChanged, d, &QQuickComboBoxPrivate::popupVisibleChanged); delete d->popup; |