From a648eb96dbef983557ffb78618d63987c27390a6 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 9 Jun 2016 21:56:31 +0200 Subject: QQuickStackView: allocate incubators on the stack Don't keep unnecessary incubator instances alive for all loaded stack elements. Just allocate it on the stack and let it go out of scope. We only use incubators to synchronously to initialize properties during construction. Change-Id: Ide56435ec9c640b9e49356f01476e36120dff5d7 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickstackview_p.cpp | 8 +++----- src/quicktemplates2/qquickstackview_p_p.h | 2 -- 2 files changed, 3 insertions(+), 7 deletions(-) (limited to 'src/quicktemplates2') diff --git a/src/quicktemplates2/qquickstackview_p.cpp b/src/quicktemplates2/qquickstackview_p.cpp index 5a83f5e5..96f70d80 100644 --- a/src/quicktemplates2/qquickstackview_p.cpp +++ b/src/quicktemplates2/qquickstackview_p.cpp @@ -72,7 +72,7 @@ private: QQuickStackElement::QQuickStackElement() : QQuickItemViewTransitionableItem(nullptr), index(-1), init(false), removal(false), ownItem(false), ownComponent(false), widthValid(false), heightValid(false), - context(nullptr), component(nullptr), incubator(nullptr), view(nullptr), + context(nullptr), component(nullptr), view(nullptr), status(QQuickStackView::Inactive) { } @@ -107,7 +107,6 @@ QQuickStackElement::~QQuickStackElement() } delete context; - delete incubator; } QQuickStackElement *QQuickStackElement::fromString(const QString &str, QQuickStackView *view) @@ -144,9 +143,8 @@ bool QQuickStackElement::load(QQuickStackView *parent) context = new QQmlContext(creationContext); context->setContextObject(parent); - delete incubator; - incubator = new QQuickStackIncubator(this); - component->create(*incubator, context); + QQuickStackIncubator incubator(this); + component->create(incubator, context); if (component->isError()) qWarning() << qPrintable(component->errorString().trimmed()); } else { diff --git a/src/quicktemplates2/qquickstackview_p_p.h b/src/quicktemplates2/qquickstackview_p_p.h index 679cee09..e57353f3 100644 --- a/src/quicktemplates2/qquickstackview_p_p.h +++ b/src/quicktemplates2/qquickstackview_p_p.h @@ -58,7 +58,6 @@ QT_BEGIN_NAMESPACE class QQmlContext; class QQmlComponent; -class QQmlIncubator; class QQuickStackElement : public QQuickItemViewTransitionableItem, public QQuickItemChangeListener { @@ -93,7 +92,6 @@ public: bool heightValid; QQmlContext *context; QQmlComponent *component; - QQmlIncubator *incubator; QQuickStackView *view; QPointer originalParent; QQuickStackView::Status status; -- cgit v1.2.3