aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickpopup.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2016-09-26 13:35:13 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2016-09-26 14:38:00 +0000
commit0e3636a4692c9cf89d994f3fe5c1c110b4c6ee61 (patch)
tree35a6cce16c40ba0cde663ff8c41086d19b527dc9 /src/quicktemplates2/qquickpopup.cpp
parent11b066beb45e7da084c6f792cf9421d48d4b40bf (diff)
Create contentItem lazily where possible
The existence of a content item is obligatory for such controls that alias the contentData and contentChildren properties to the data and children properties of the content item. Even though we created empty content items in QML to ensure one always exists, it did not not guarantee that a content item would exist for custom styles. Furthermore, the empty content item was unnecessarily created and destroyed when the property was overridden for a customized control in QML. This change creates the content item lazily where required, ensuring that it always exists even for custom styles, but does not create it in case a content item is supplied from QML. Task-number: QTBUG-54347 Task-number: QTBUG-56038 Change-Id: I714ef4f8c366f0f449b922b2c16c0ec653fbd364 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickpopup.cpp')
-rw-r--r--src/quicktemplates2/qquickpopup.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp
index d2625c3e..a8e07533 100644
--- a/src/quicktemplates2/qquickpopup.cpp
+++ b/src/quicktemplates2/qquickpopup.cpp
@@ -352,6 +352,8 @@ public:
void resolveFont() override;
+ QQuickItem *getContentItem() override;
+
QQuickPopup *popup;
};
@@ -378,6 +380,14 @@ void QQuickPopupItemPrivate::resolveFont()
inheritFont(window->font());
}
+QQuickItem *QQuickPopupItemPrivate::getContentItem()
+{
+ Q_Q(QQuickPopupItem);
+ if (!contentItem)
+ contentItem = new QQuickItem(q);
+ return contentItem;
+}
+
QQuickPopupItem::QQuickPopupItem(QQuickPopup *popup) :
QQuickControl(*(new QQuickPopupItemPrivate(popup)), nullptr)
{