diff options
Diffstat (limited to 'src/quicktemplates2/qquickcontrol.cpp')
-rw-r--r-- | src/quicktemplates2/qquickcontrol.cpp | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp index 1db8932b..76d6a688 100644 --- a/src/quicktemplates2/qquickcontrol.cpp +++ b/src/quicktemplates2/qquickcontrol.cpp @@ -48,6 +48,7 @@ #include "qquickpopup_p.h" #include "qquickpopupitem_p_p.h" #include "qquickapplicationwindow_p.h" +#include "qquickdeferredexecute_p_p.h" #include <QtGui/private/qguiapplication_p.h> #include <QtGui/qpa/qplatformtheme.h> @@ -279,6 +280,8 @@ void QQuickControlPrivate::resizeContent() QQuickItem *QQuickControlPrivate::getContentItem() { + if (!contentItem) + executeContentItem(); return contentItem; } @@ -289,7 +292,7 @@ void QQuickControlPrivate::setContentItem_helper(QQuickItem *item, bool notify) return; q->contentItemChange(item, contentItem); - destroyDelegate(contentItem, q); + delete contentItem; contentItem = item; if (item) { @@ -299,7 +302,7 @@ void QQuickControlPrivate::setContentItem_helper(QQuickItem *item, bool notify) resizeContent(); } - if (notify) + if (notify && !contentItem.isExecuting()) emit q->contentItemChanged(); } @@ -644,6 +647,34 @@ bool QQuickControlPrivate::calcHoverEnabled(const QQuickItem *item) } #endif +static inline QString contentItemName() { return QStringLiteral("contentItem"); } + +void QQuickControlPrivate::executeContentItem(bool complete) +{ + Q_Q(QQuickControl); + if (contentItem.wasExecuted()) + return; + + if (!contentItem) + quickBeginDeferred(q, contentItemName(), contentItem); + if (complete) + quickCompleteDeferred(q, contentItemName(), contentItem); +} + +static inline QString backgroundName() { return QStringLiteral("background"); } + +void QQuickControlPrivate::executeBackground(bool complete) +{ + Q_Q(QQuickControl); + if (background.wasExecuted()) + return; + + if (!background) + quickBeginDeferred(q, backgroundName(), background); + if (complete) + quickCompleteDeferred(q, backgroundName(), background); +} + /* Cancels incubation recursively to avoid "Object destroyed during incubation" (QTBUG-50992) */ @@ -1270,7 +1301,9 @@ void QQuickControl::setWheelEnabled(bool enabled) */ QQuickItem *QQuickControl::background() const { - Q_D(const QQuickControl); + QQuickControlPrivate *d = const_cast<QQuickControlPrivate *>(d_func()); + if (!d->background) + d->executeBackground(); return d->background; } @@ -1280,7 +1313,7 @@ void QQuickControl::setBackground(QQuickItem *background) if (d->background == background) return; - QQuickControlPrivate::destroyDelegate(d->background, this); + delete d->background; d->background = background; if (background) { background->setParentItem(this); @@ -1289,7 +1322,8 @@ void QQuickControl::setBackground(QQuickItem *background) if (isComponentComplete()) d->resizeBackground(); } - emit backgroundChanged(); + if (!d->background.isExecuting()) + emit backgroundChanged(); } /*! @@ -1414,6 +1448,8 @@ void QQuickControl::classBegin() void QQuickControl::componentComplete() { Q_D(QQuickControl); + d->executeBackground(true); + d->executeContentItem(true); QQuickItem::componentComplete(); d->resizeContent(); if (!d->hasLocale) |