From ce698d243f31d2b9adcdf2b6b40f5844c200b159 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 1 Sep 2010 11:54:14 +1000 Subject: Support JS "in" operator on QML objects QTBUG-12837 --- src/declarative/qml/qdeclarativeobjectscriptclass.cpp | 2 +- tests/auto/declarative/qdeclarativeecmascript/data/in.qml | 7 +++++++ .../qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp | 11 +++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tests/auto/declarative/qdeclarativeecmascript/data/in.qml diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp index 3af892d..f439151 100644 --- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp +++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp @@ -192,7 +192,7 @@ QDeclarativeObjectScriptClass::queryProperty(QObject *obj, const Identifier &nam if (!(hints & ImplicitObject)) { local.coreIndex = -1; lastData = &local; - return QScriptClass::HandlesReadAccess | QScriptClass::HandlesWriteAccess; + return QScriptClass::HandlesWriteAccess; } return 0; diff --git a/tests/auto/declarative/qdeclarativeecmascript/data/in.qml b/tests/auto/declarative/qdeclarativeecmascript/data/in.qml new file mode 100644 index 0000000..0b5b0ba --- /dev/null +++ b/tests/auto/declarative/qdeclarativeecmascript/data/in.qml @@ -0,0 +1,7 @@ +import Qt 4.7 + +Item { + id: root + property bool test1: "x" in root + property bool test2: !("foo" in root) +} diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 496cc05..76ca964 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -159,6 +159,7 @@ private slots: void qtbug_11600(); void nonscriptable(); void deleteLater(); + void in(); void include(); @@ -2553,6 +2554,16 @@ void tst_qdeclarativeecmascript::deleteLater() delete o; } +void tst_qdeclarativeecmascript::in() +{ + QDeclarativeComponent component(&engine, TEST_FILE("in.qml")); + QObject *o = component.create(); + QVERIFY(o != 0); + QCOMPARE(o->property("test1").toBool(), true); + QCOMPARE(o->property("test2").toBool(), true); + delete o; +} + QTEST_MAIN(tst_qdeclarativeecmascript) #include "tst_qdeclarativeecmascript.moc" -- cgit v0.12