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/qml/qqmlxmlhttprequest.cpp | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'src/qml/qml/qqmlxmlhttprequest.cpp') diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index e374e471e3..0730cbc363 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -203,7 +203,7 @@ public: // JS API static void destroy(Managed *that) { - that->as()->d()->~Data(); + static_cast(that)->d()->~Data(); } static ReturnedValue get(Managed *m, String *name, bool *hasProperty); static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty); @@ -234,7 +234,7 @@ public: // JS API static void destroy(Managed *that) { - that->as()->d()->~Data(); + static_cast(that)->d()->~Data(); } static ReturnedValue get(Managed *m, String *name, bool *hasProperty); static ReturnedValue getIndexed(Managed *m, uint index, bool *hasProperty); @@ -324,7 +324,7 @@ struct Node : public Object // JS API static void destroy(Managed *that) { - that->as()->d()->~Data(); + static_cast(that)->d()->~Data(); } // C++ API @@ -916,10 +916,9 @@ ReturnedValue NamedNodeMap::getIndexed(Managed *m, uint index, bool *hasProperty ReturnedValue NamedNodeMap::get(Managed *m, String *name, bool *hasProperty) { - NamedNodeMap *r = m->as(); + Q_ASSERT(m->as()); + NamedNodeMap *r = static_cast(m); QV4::ExecutionEngine *v4 = m->engine(); - if (!r) - return v4->currentContext()->throwTypeError(); name->makeIdentifier(); if (name->equals(v4->id_length)) @@ -949,13 +948,9 @@ ReturnedValue NamedNodeMap::create(QV8Engine *engine, NodeImpl *data, const QLis ReturnedValue NodeList::getIndexed(Managed *m, uint index, bool *hasProperty) { + Q_ASSERT(m->as()); QV4::ExecutionEngine *v4 = m->engine(); - NodeList *r = m->as(); - if (!r) { - if (hasProperty) - *hasProperty = false; - return v4->currentContext()->throwTypeError(); - } + NodeList *r = static_cast(m); QV8Engine *engine = v4->v8Engine; @@ -971,10 +966,9 @@ ReturnedValue NodeList::getIndexed(Managed *m, uint index, bool *hasProperty) ReturnedValue NodeList::get(Managed *m, String *name, bool *hasProperty) { + Q_ASSERT(m->as()); QV4::ExecutionEngine *v4 = m->engine(); - NodeList *r = m->as(); - if (!r) - return v4->currentContext()->throwTypeError(); + NodeList *r = static_cast(m); name->makeIdentifier(); @@ -1608,7 +1602,7 @@ struct QQmlXMLHttpRequestWrapper : public Object V4_OBJECT(Object) static void destroy(Managed *that) { - that->as()->d()->~Data(); + static_cast(that)->d()->~Data(); } }; @@ -1638,7 +1632,7 @@ struct QQmlXMLHttpRequestCtor : public FunctionObject }; V4_OBJECT(FunctionObject) static void markObjects(Managed *that, ExecutionEngine *e) { - QQmlXMLHttpRequestCtor *c = that->as(); + QQmlXMLHttpRequestCtor *c = static_cast(that); if (c->d()->proto) c->d()->proto->mark(e); FunctionObject::markObjects(that, e); -- cgit v1.2.3