From 0704d2be63b484cb579c1507223db3f914b1338a Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 30 Oct 2014 22:30:01 +0100 Subject: Get rid of !this and similar constructs The C++ standard doesn't allow calling member functions on a mull object. Fix all such places, by moving the checks to the caller where required. Change-Id: I10fb22acaf0324d8ffd3a6d8e19152e5d32f56bb Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4managed_p.h | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/qml/jsruntime/qv4managed_p.h') diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h index ce0ee973e8..e679017b7e 100644 --- a/src/qml/jsruntime/qv4managed_p.h +++ b/src/qml/jsruntime/qv4managed_p.h @@ -269,9 +269,7 @@ public: template T *as() { - // ### FIXME: - if (!this || !internalClass()) - return 0; + Q_ASSERT(internalClass()); #if !defined(QT_NO_QOBJECT_CHECK) static_cast(this)->qt_check_for_QMANAGED_macro(static_cast(this)); #endif @@ -285,9 +283,7 @@ public: } template const T *as() const { - // ### FIXME: - if (!this) - return 0; + Q_ASSERT(internalClass()); #if !defined(QT_NO_QOBJECT_CHECK) static_cast(this)->qt_check_for_QMANAGED_macro(static_cast(const_cast(this))); #endif @@ -362,23 +358,23 @@ inline Managed *value_cast(const Value &v) { template inline T *managed_cast(Managed *m) { - return m->as(); + return m ? m->as() : 0; } template<> inline String *managed_cast(Managed *m) { - return m->asString(); + return m ? m->asString() : 0; } template<> inline Object *managed_cast(Managed *m) { - return m->asObject(); + return m ? m->asObject() : 0; } template<> inline FunctionObject *managed_cast(Managed *m) { - return m->asFunctionObject(); + return m ? m->asFunctionObject() : 0; } } -- cgit v1.2.3