History

Add hasProperty for checking whether a property exists

Dale Glass committed 3 years ago

Commit ac7ebe21 parent 5f2c13d6 files · +47 −5Browse files

Showing the changes to libraries/script-engine/src/ScriptValueUtils.cpp (1 of 6 files). Show all

Unified · Split

libraries/script-engine/src/ScriptValueUtils.cpp+4−4
@@ -140,7 +140,7 @@ bool vec2FromScriptValue(const ScriptValue& object, glm::vec2& vec2) { · 139 unmodified lines
140140
141141 ScriptValue vec3ToScriptValue(ScriptEngine* engine, const glm::vec3& vec3) {
142142 auto prototype = engine->globalObject().property("__hifi_vec3__");
143− if (!prototype.property("defined").toBool()) {
143+ if (!prototype.hasProperty("defined") || !prototype.property("defined").toBool()) {
144144 prototype = engine->evaluate(
145145 "__hifi_vec3__ = Object.defineProperties({}, { "
146146 "defined: { value: true },"
@@ -648,7 +648,7 @@ ScriptValue qColorToScriptValue(ScriptEngine* engine, const QColor& color) { · 501 unmodified lines
648648 }
649649
650650 /**jsdoc
651− * An axis-aligned cube, defined as the bottom right near (minimum axes values) corner of the cube plus the dimension of its
651+ * An axis-aligned cube, defined as the bottom right near (minimum axes values) corner of the cube plus the dimension of its
652652 * sides.
653653 * @typedef {object} AACube
654654 * @property {number} x - X coordinate of the brn corner of the cube.
@@ -812,8 +812,8 @@ bool qSizeFFromScriptValue(const ScriptValue& object, QSizeF& qSizeF) { · 157 unmodified lines
812812 * The details of an animation that is playing.
813813 * @typedef {object} Avatar.AnimationDetails
814814 * @property {string} role - <em>Not used.</em>
815− * @property {string} url - The URL to the animation file. Animation files need to be in glTF or FBX format but only need to
816− * contain the avatar skeleton and animation data. glTF models may be in JSON or binary format (".gltf" or ".glb" URLs
815+ * @property {string} url - The URL to the animation file. Animation files need to be in glTF or FBX format but only need to
816+ * contain the avatar skeleton and animation data. glTF models may be in JSON or binary format (".gltf" or ".glb" URLs
817817 * respectively).
818818 * <p><strong>Warning:</strong> glTF animations currently do not always animate correctly.</p>
819819 * @property {number} fps - The frames per second(FPS) rate for the animation playback. 30 FPS is normal speed.