Hi,

I have a question concerning the exact semantics of QJSValue::setProperty and QJSValue::deleteProperty functions. Specifically, what happens if I do something akin to this example:

*) I evaluate a script using the QJSEngine::evaluate() function. As a consequence I now have a set of properties in the global context of the script engine corresponding to the script defined properties, such as objects and functions *) I copy? one of these functions into a container object living in the global context using container.setProperty("functionName", function) *) I delete the function object in the global context global.deleteProperty("functionName")

My question is, does deleting the property "functionName" in the global context also invalidate the copy in the container?

According to the QJSValue documentation:
Note that a QJSValue for which isObject() is true only carries a reference to an actual object; copying the QJSValue will only copy the object reference, not the object itself. If you want to clone an object (i.e. copy an object's properties to another object), you can do so with the help of a for-in statement in script code, or QJSValueIterator in C++.
copying a QJSValue results in a flat copy, if the QJSValue wraps an object. In JavaScript functions are objects. So, I am unsure, if the global.deleteProperty("functionName") call just deletes this particular object reference, or the object itself.

Thanks for any help,
Daniel




_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to