From 79745bf95cfb656b7ea75850c2b378cac3ea18ec Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 15 Jun 2016 16:21:15 +0200 Subject: Expose QQmlComponentPrivate::setInitialProperties() QQuickStackView::push() can be used to push not only URLs or Components, but also plain Items. This patch makes it possible for StackView to initialize properties for plain Items without having to create a useless QQmlComponent instance just to be able to call initializeObjectWithInitialProperties(). Change-Id: Id538028d09c1319da56b26695ebd407f4c0fa27a Reviewed-by: Simon Hausmann --- src/qml/qml/qqmlcomponent.cpp | 6 +++--- src/qml/qml/qqmlcomponent_p.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index e615318636..52f6837842 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1174,7 +1174,7 @@ static void QQmlComponent_setQmlParent(QObject *me, QObject *parent) */ -static void setInitialProperties(QV4::ExecutionEngine *engine, QV4::QmlContext *qmlContext, const QV4::Value &o, const QV4::Value &v) +void QQmlComponentPrivate::setInitialProperties(QV4::ExecutionEngine *engine, QV4::QmlContext *qmlContext, const QV4::Value &o, const QV4::Value &v) { QV4::Scope scope(engine); QV4::ScopedObject object(scope); @@ -1263,7 +1263,7 @@ void QQmlComponent::createObject(QQmlV4Function *args) if (!valuemap->isUndefined()) { QV4::Scoped qmlContext(scope, v4->qmlContext()); - setInitialProperties(v4, qmlContext, object, valuemap); + QQmlComponentPrivate::setInitialProperties(v4, qmlContext, object, valuemap); } d->completeCreate(); @@ -1496,7 +1496,7 @@ void QV4::QmlIncubatorObject::setInitialState(QObject *o) QV4::Scope scope(v4); QV4::ScopedObject obj(scope, QV4::QObjectWrapper::wrap(v4, o)); QV4::Scoped qmlCtxt(scope, d()->qmlContext); - setInitialProperties(v4, qmlCtxt, obj, d()->valuemap); + QQmlComponentPrivate::setInitialProperties(v4, qmlCtxt, obj, d()->valuemap); } } diff --git a/src/qml/qml/qqmlcomponent_p.h b/src/qml/qml/qqmlcomponent_p.h index be69986117..3a84e724da 100644 --- a/src/qml/qml/qqmlcomponent_p.h +++ b/src/qml/qml/qqmlcomponent_p.h @@ -86,6 +86,7 @@ public: QObject *beginCreate(QQmlContextData *); void completeCreate(); void initializeObjectWithInitialProperties(QV4::QmlContext *qmlContext, const QV4::Value &valuemap, QObject *toCreate); + static void setInitialProperties(QV4::ExecutionEngine *engine, QV4::QmlContext *qmlContext, const QV4::Value &o, const QV4::Value &v); QQmlTypeData *typeData; virtual void typeDataReady(QQmlTypeData *); -- cgit v1.2.3