From 2eb67032ea81aa105a854644f337ad5377c2994e Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 15 Oct 2009 18:28:03 +1000 Subject: Fix dynamic example Had some accidental global vars Task-number: One of the QT-2270s --- examples/declarative/dynamic/dynamic.qml | 8 +++++--- src/declarative/qml/qmlobjectscriptclass.cpp | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/declarative/dynamic/dynamic.qml b/examples/declarative/dynamic/dynamic.qml index 66fdf87..2c6a8e0 100644 --- a/examples/declarative/dynamic/dynamic.qml +++ b/examples/declarative/dynamic/dynamic.qml @@ -8,6 +8,7 @@ Rectangle { Script { source: "dynamic.js" } property bool extendStars: false + property var fourthBox: undefined Item { id: targetItem; x: 100; y: 100; } Item { id: targetItem2; x: 0; y: 300; } @@ -20,7 +21,7 @@ Rectangle { MouseRegion { anchors.fill: parent - onClicked: { a = createWithComponent(); } + onClicked: { var a = createWithComponent(); } } } @@ -47,8 +48,8 @@ Rectangle { MouseRegion { anchors.fill: parent onClicked: { - if (fourthBox == null) { - a = createQml(targetItem2); + if (fourthBox == null || fourthBox == undefined) { + var a = createQml(targetItem2); if (a != null) { a.parent = targetItem2;//BUG: this should happen automatically fourthBox = a; @@ -68,6 +69,7 @@ Rectangle { Particles { x: 0 y: 0 + z: 10 count: 20 lifeSpan: 500 width: 100 diff --git a/src/declarative/qml/qmlobjectscriptclass.cpp b/src/declarative/qml/qmlobjectscriptclass.cpp index 122db51..ae2cfcc 100644 --- a/src/declarative/qml/qmlobjectscriptclass.cpp +++ b/src/declarative/qml/qmlobjectscriptclass.cpp @@ -250,6 +250,7 @@ void QmlObjectScriptClass::setProperty(QObject *obj, Q_ASSERT(lastData); QmlEnginePrivate *enginePriv = QmlEnginePrivate::get(engine); + Q_ASSERT(enginePriv->currentExpression); // ### Can well known types be optimized? QVariant v = QmlScriptClass::toVariant(engine, value); -- cgit v0.12