summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-08-10 11:01:42 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-08-10 11:01:42 (GMT)
commitfab932713af6dfa7aad06ddfde774d25f5222472 (patch)
treef96e87bbc0fe3a5448c105bf161fd4bf5bfa464d
parent34511e1001471ed4041794640aefe508f50ad01c (diff)
downloadQt-fab932713af6dfa7aad06ddfde774d25f5222472.zip
Qt-fab932713af6dfa7aad06ddfde774d25f5222472.tar.gz
Qt-fab932713af6dfa7aad06ddfde774d25f5222472.tar.bz2
implement QScriptClass property query semantics of old back-end
Look up the property as a normal JS property before falling back to the dynamic query mechanism. This is the documented behavior.
-rw-r--r--src/script/bridge/qscriptclassobject.cpp7
-rw-r--r--tests/auto/qscriptclass/tst_qscriptclass.cpp4
2 files changed, 9 insertions, 2 deletions
diff --git a/src/script/bridge/qscriptclassobject.cpp b/src/script/bridge/qscriptclassobject.cpp
index 2c28ca0..50547e81 100644
--- a/src/script/bridge/qscriptclassobject.cpp
+++ b/src/script/bridge/qscriptclassobject.cpp
@@ -89,6 +89,11 @@ bool ClassObjectDelegate::getOwnPropertySlot(QScriptObject* object,
const JSC::Identifier &propertyName,
JSC::PropertySlot &slot)
{
+ // for compatibility with the old back-end, normal JS properties
+ // are queried first.
+ if (QScriptObjectDelegate::getOwnPropertySlot(object, exec, propertyName, slot))
+ return true;
+
QScriptEnginePrivate *engine = scriptEngineFromExec(exec);
QScriptValue scriptObject = engine->scriptValueFromJSCValue(object);
QString name = qtStringFromJSCUString(propertyName.ustring());
@@ -101,7 +106,7 @@ bool ClassObjectDelegate::getOwnPropertySlot(QScriptObject* object,
slot.setValue(engine->scriptValueToJSCValue(value));
return true;
}
- return QScriptObjectDelegate::getOwnPropertySlot(object, exec, propertyName, slot);
+ return false;
}
void ClassObjectDelegate::put(QScriptObject* object, JSC::ExecState *exec,
diff --git a/tests/auto/qscriptclass/tst_qscriptclass.cpp b/tests/auto/qscriptclass/tst_qscriptclass.cpp
index d957ee3..2bc8778 100644
--- a/tests/auto/qscriptclass/tst_qscriptclass.cpp
+++ b/tests/auto/qscriptclass/tst_qscriptclass.cpp
@@ -652,9 +652,11 @@ void tst_QScriptClass::getAndSetProperty()
QVERIFY(cls.lastQueryPropertyFlags() == QScriptClass::HandlesWriteAccess);
// re-read property
+ // When a QScriptClass doesn't want to handle a property write,
+ // that property becomes a normal property and the QScriptClass
+ // shall not be queried about it again.
cls.clearReceivedArgs();
QVERIFY(o.property(s).strictlyEquals(num));
- QEXPECT_FAIL("", "What's the purpose of this check?", Continue);
QVERIFY(!cls.lastQueryPropertyObject().isValid());
}
}