diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2018-01-08 08:49:33 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2018-01-08 08:49:33 +0000 |
commit | 10b8f6af42a1cd80273d0a2d36e75b79078b5994 (patch) | |
tree | 366acd2409145aba86d0ee752f15dfbf46c20b9d /src/quicktemplates2/qquicktextarea.cpp | |
parent | d26d6a46bb5793e4a3bdc2c7a387f8f8a89b349b (diff) | |
parent | 1fcec5bf1e208a4f32ef4f3afa54684358a11a1d (diff) |
Merge "Merge remote-tracking branch 'origin/5.9' into 5.10" into refs/staging/5.10
Diffstat (limited to 'src/quicktemplates2/qquicktextarea.cpp')
-rw-r--r-- | src/quicktemplates2/qquicktextarea.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp index 02e84a35..d2458c24 100644 --- a/src/quicktemplates2/qquicktextarea.cpp +++ b/src/quicktemplates2/qquicktextarea.cpp @@ -39,6 +39,7 @@ #include "qquickcontrol_p.h" #include "qquickcontrol_p_p.h" #include "qquickscrollview_p.h" +#include "qquickdeferredexecute_p_p.h" #include <QtQml/qqmlinfo.h> #include <QtQuick/private/qquickitem_p.h> @@ -437,6 +438,20 @@ QAccessible::Role QQuickTextAreaPrivate::accessibleRole() const } #endif +static inline QString backgroundName() { return QStringLiteral("background"); } + +void QQuickTextAreaPrivate::executeBackground(bool complete) +{ + Q_Q(QQuickTextArea); + if (background.wasExecuted()) + return; + + if (!background) + quickBeginDeferred(q, backgroundName(), background); + if (complete) + quickCompleteDeferred(q, backgroundName(), background); +} + QQuickTextArea::QQuickTextArea(QQuickItem *parent) : QQuickTextEdit(*(new QQuickTextAreaPrivate), parent) { @@ -490,7 +505,9 @@ void QQuickTextArea::setFont(const QFont &font) */ QQuickItem *QQuickTextArea::background() const { - Q_D(const QQuickTextArea); + QQuickTextAreaPrivate *d = const_cast<QQuickTextAreaPrivate *>(d_func()); + if (!d->background) + d->executeBackground(); return d->background; } @@ -500,7 +517,7 @@ void QQuickTextArea::setBackground(QQuickItem *background) if (d->background == background) return; - QQuickControlPrivate::destroyDelegate(d->background, this); + delete d->background; d->background = background; if (background) { background->setParentItem(this); @@ -509,7 +526,8 @@ void QQuickTextArea::setBackground(QQuickItem *background) if (isComponentComplete()) d->resizeBackground(); } - emit backgroundChanged(); + if (!d->background.isExecuting()) + emit backgroundChanged(); } /*! @@ -686,6 +704,7 @@ void QQuickTextArea::classBegin() void QQuickTextArea::componentComplete() { Q_D(QQuickTextArea); + d->executeBackground(true); QQuickTextEdit::componentComplete(); #if QT_CONFIG(quicktemplates2_hover) if (!d->explicitHoverEnabled) |