From 10942bd94b20bc72dd699425bb0431524148e742 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 13 Feb 2015 14:08:33 +0100 Subject: 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 --- src/qml/jsruntime/qv4dateobject_p.h | 2 +- src/qml/jsruntime/qv4errorobject_p.h | 2 +- src/qml/jsruntime/qv4jsonobject.cpp | 2 +- src/qml/jsruntime/qv4managed_p.h | 3 --- src/qml/jsruntime/qv4object_p.h | 2 +- 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(this) : 0; + return isManaged() && m && m->vtable->type == Managed::Type_DateObject ? static_cast(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(this) : 0; + return isManaged() && m && m->vtable->isErrorObject ? reinterpret_cast(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()) value = so->d()->value; - else if (BooleanObject *b =o->asBooleanObject()) + else if (BooleanObject *b = o->as()) 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(this) : 0; } - ArgumentsObject *asArgumentsObject() { return d()->vtable->type == Type_ArgumentsObject ? reinterpret_cast(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(this) : 0; + return isManaged() && m && m->vtable->type == Managed::Type_ArrayObject ? static_cast(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(this) : 0; + return isManaged() && m && m->vtable->isString ? static_cast(this) : 0; } } -- cgit v1.2.3