diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2010-01-05 10:09:33 (GMT) |
---|---|---|
committer | Jason McDonald <jason.mcdonald@nokia.com> | 2010-01-07 10:01:07 (GMT) |
commit | 63855f391ba4440ed037b808c465aa068548458c (patch) | |
tree | 3b32c95165271275cc2f5ae753793d768a0bf69b | |
parent | c7ea47fcb193c1004db0c66397bada9146ab5ea7 (diff) | |
download | Qt-63855f391ba4440ed037b808c465aa068548458c.zip Qt-63855f391ba4440ed037b808c465aa068548458c.tar.gz Qt-63855f391ba4440ed037b808c465aa068548458c.tar.bz2 |
QScript: Lookup the native setter from the prototype
Usefull if we have 'native' properties with setter in a prototype
This happen if you use a QObject wrapper as a prototype.
Use getPropertyDescriptor that look up the prototype in order to
know if we have a setter.
Note that we cannot relly on PropertDescriptor::isAccessorDescriptor
as the Getter or Setter attributes are not necesserly updated correctly
when updating properties. (See the workaround QScriptValuePrivate::propertyFlags,
and tst_QScriptValue::getSetProperty with object7)
Task-number: QTBUG-5749 (also need the previous patch)
Reviewed-by: Kent Hansen
(cherry picked from commit e715a7f4cfad454b9c966fa2938cbe9a92ce49fb)
-rw-r--r-- | src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSObject.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSObject.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSObject.cpp index d7f5344..01f74ac 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSObject.cpp +++ b/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSObject.cpp @@ -115,9 +115,17 @@ void JSObject::put(ExecState* exec, const Identifier& propertyName, JSValue valu return; for (JSObject* obj = this; ; obj = asObject(prototype)) { +#ifdef QT_BUILD_SCRIPT_LIB + PropertyDescriptor descriptor; + if (obj->getPropertyDescriptor(exec, propertyName, descriptor)) { + JSObject* setterFunc; + if ((descriptor.isAccessorDescriptor() && ((setterFunc = asObject(descriptor.setter())), true)) + || (descriptor.value().isGetterSetter() && ((setterFunc = asGetterSetter(descriptor.value())->setter()), true))) { +#else if (JSValue gs = obj->getDirect(propertyName)) { if (gs.isGetterSetter()) { - JSObject* setterFunc = asGetterSetter(gs)->setter(); + JSObject* setterFunc = asGetterSetter(gs)->setter(); +#endif if (!setterFunc) { throwSetterError(exec); return; |