diff options
author | Lars Knoll <lars.knoll@theqtcompany.com> | 2015-02-13 14:08:33 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-04-21 14:21:42 +0000 |
commit | 10942bd94b20bc72dd699425bb0431524148e742 (patch) | |
tree | 3ba63ffaa988db5ad1584ab76759882caf382c5f | |
parent | 331033c77416daf41532fc9ac20cd560428fe648 (diff) |
Remove last asFoo() methods from Managed
Also add some safety checks in case the heap pointer
inside the Value is 0.
Change-Id: I61d37410c10c34f197175dbbd9ea8fa8c95c12cd
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
-rw-r--r-- | src/qml/jsruntime/qv4dateobject_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4errorobject_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4jsonobject.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4managed_p.h | 3 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4object_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4string_p.h | 2 |
6 files changed, 5 insertions, 8 deletions
diff --git a/src/qml/jsruntime/qv4dateobject_p.h b/src/qml/jsruntime/qv4dateobject_p.h index 200466064a..a4c508a628 100644 --- a/src/qml/jsruntime/qv4dateobject_p.h +++ b/src/qml/jsruntime/qv4dateobject_p.h @@ -82,7 +82,7 @@ struct DateObject: Object { template<> inline const DateObject *Value::as() const { - return isManaged() && m->vtable->type == Managed::Type_DateObject ? static_cast<const DateObject *>(this) : 0; + return isManaged() && m && m->vtable->type == Managed::Type_DateObject ? static_cast<const DateObject *>(this) : 0; } struct DateCtor: FunctionObject diff --git a/src/qml/jsruntime/qv4errorobject_p.h b/src/qml/jsruntime/qv4errorobject_p.h index 7451c9fdf5..e26654e931 100644 --- a/src/qml/jsruntime/qv4errorobject_p.h +++ b/src/qml/jsruntime/qv4errorobject_p.h @@ -142,7 +142,7 @@ struct ErrorObject: Object { template<> inline const ErrorObject *Value::as() const { - return isManaged() && m->vtable->isErrorObject ? reinterpret_cast<const ErrorObject *>(this) : 0; + return isManaged() && m && m->vtable->isErrorObject ? reinterpret_cast<const ErrorObject *>(this) : 0; } struct EvalErrorObject: ErrorObject { diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp index 74a25324c1..f6e9f5a3d1 100644 --- a/src/qml/jsruntime/qv4jsonobject.cpp +++ b/src/qml/jsruntime/qv4jsonobject.cpp @@ -704,7 +704,7 @@ QString Stringify::Str(const QString &key, const Value &v) value = Encode(n->value()); else if (StringObject *so = o->as<StringObject>()) value = so->d()->value; - else if (BooleanObject *b =o->asBooleanObject()) + else if (BooleanObject *b = o->as<BooleanObject>()) value = Encode(b->value()); } diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h index 664bbb3137..a5d941e864 100644 --- a/src/qml/jsruntime/qv4managed_p.h +++ b/src/qml/jsruntime/qv4managed_p.h @@ -150,9 +150,6 @@ public: }; Q_MANAGED_TYPE(Invalid) - BooleanObject *asBooleanObject() { return d()->vtable->type == Type_BooleanObject ? reinterpret_cast<BooleanObject *>(this) : 0; } - ArgumentsObject *asArgumentsObject() { return d()->vtable->type == Type_ArgumentsObject ? reinterpret_cast<ArgumentsObject *>(this) : 0; } - bool isListType() const { return d()->vtable->type == Type_QmlSequence; } bool isArrayObject() const { return d()->vtable->type == Type_ArrayObject; } diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h index 1348ab5177..94709c2941 100644 --- a/src/qml/jsruntime/qv4object_p.h +++ b/src/qml/jsruntime/qv4object_p.h @@ -460,7 +460,7 @@ inline void Object::arraySet(uint index, const Value &value) template<> inline const ArrayObject *Value::as() const { - return isManaged() && m->vtable->type == Managed::Type_ArrayObject ? static_cast<const ArrayObject *>(this) : 0; + return isManaged() && m && m->vtable->type == Managed::Type_ArrayObject ? static_cast<const ArrayObject *>(this) : 0; } #ifndef V4_BOOTSTRAP diff --git a/src/qml/jsruntime/qv4string_p.h b/src/qml/jsruntime/qv4string_p.h index b6712ece40..a225825031 100644 --- a/src/qml/jsruntime/qv4string_p.h +++ b/src/qml/jsruntime/qv4string_p.h @@ -186,7 +186,7 @@ public: template<> inline const String *Value::as() const { - return isManaged() && m->vtable->isString ? static_cast<const String *>(this) : 0; + return isManaged() && m && m->vtable->isString ? static_cast<const String *>(this) : 0; } } |