summaryrefslogtreecommitdiffstats
path: root/src/script/api/qscriptvalue_p.h
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-08-26 14:02:30 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-08-26 14:06:55 (GMT)
commit5be87d57602d72c225943f052783c1053cd3d81a (patch)
treecf62f85855d21924aa68c9b28b7dbe5fb4dc6bf6 /src/script/api/qscriptvalue_p.h
parent478f18e37a04849f4577ded7ba60d8360b6c5c90 (diff)
downloadQt-5be87d57602d72c225943f052783c1053cd3d81a.zip
Qt-5be87d57602d72c225943f052783c1053cd3d81a.tar.gz
Qt-5be87d57602d72c225943f052783c1053cd3d81a.tar.bz2
don't crash when attempting to access properties of a JS Object that belonged to a deleted script engine
When the engine is deleted, the JSValue is invalidated, but the QScriptValue's type will still be QScriptValuePrivate::JSC. Use a new helper function, isObject(), that checks both that the value is of type JSC _and_ that it is valid, before calling JSValue::isObject() (JSValue::isObject() assumes that the value is valid).
Diffstat (limited to 'src/script/api/qscriptvalue_p.h')
-rw-r--r--src/script/api/qscriptvalue_p.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/script/api/qscriptvalue_p.h b/src/script/api/qscriptvalue_p.h
index c440013..6d57d32 100644
--- a/src/script/api/qscriptvalue_p.h
+++ b/src/script/api/qscriptvalue_p.h
@@ -85,6 +85,7 @@ public:
inline void initFrom(const QString &value);
inline bool isJSC() const;
+ inline bool isObject() const;
QVariant &variantValue() const;
void setVariantValue(const QVariant &value);
@@ -144,6 +145,11 @@ inline bool QScriptValuePrivate::isJSC() const
return (type == JSC);
}
+inline bool QScriptValuePrivate::isObject() const
+{
+ return isJSC() && jscValue && jscValue.isObject();
+}
+
// Rest of inline functions implemented in qscriptengine_p.h
QT_END_NAMESPACE