diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2010-01-05 10:09:33 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2010-01-05 10:09:33 (GMT) |
commit | e715a7f4cfad454b9c966fa2938cbe9a92ce49fb (patch) | |
tree | b8130e62e38b31d494aa97d81df91a8ed29aca65 | |
parent | d14ac9914753220e54f3b5cd94d122325d499776 (diff) | |
download | Qt-e715a7f4cfad454b9c966fa2938cbe9a92ce49fb.zip Qt-e715a7f4cfad454b9c966fa2938cbe9a92ce49fb.tar.gz Qt-e715a7f4cfad454b9c966fa2938cbe9a92ce49fb.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
-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; |