aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickgroupbox.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-12-19 13:38:40 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2017-12-21 14:46:30 +0000
commitc40486acc352d49398186fa32d1ccabdd5fc83c6 (patch)
treeb4f77d072020eef0bb17d4491e98daa1a048537a /src/quicktemplates2/qquickgroupbox.cpp
parent1e33020fc02b56001d805d3d66badd41480b746d (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/qquickgroupbox.cpp')
-rw-r--r--src/quicktemplates2/qquickgroupbox.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/quicktemplates2/qquickgroupbox.cpp b/src/quicktemplates2/qquickgroupbox.cpp
index 674f5b18..3c7bf715 100644
--- a/src/quicktemplates2/qquickgroupbox.cpp
+++ b/src/quicktemplates2/qquickgroupbox.cpp
@@ -91,6 +91,7 @@ class QQuickGroupBoxPrivate : public QQuickFramePrivate
public:
QQuickGroupBoxPrivate() : label(nullptr) { }
+ void cancelLabel();
void executeLabel(bool complete = false);
QString title;
@@ -99,13 +100,19 @@ public:
static inline QString labelName() { return QStringLiteral("label"); }
+void QQuickGroupBoxPrivate::cancelLabel()
+{
+ Q_Q(QQuickGroupBox);
+ quickCancelDeferred(q, labelName());
+}
+
void QQuickGroupBoxPrivate::executeLabel(bool complete)
{
Q_Q(QQuickGroupBox);
if (label.wasExecuted())
return;
- if (!label)
+ if (!label || complete)
quickBeginDeferred(q, labelName(), label);
if (complete)
quickCompleteDeferred(q, labelName(), label);
@@ -162,6 +169,9 @@ void QQuickGroupBox::setLabel(QQuickItem *label)
if (d->label == label)
return;
+ if (!d->label.isExecuting())
+ d->cancelLabel();
+
delete d->label;
d->label = label;
if (label && !label->parentItem())