diff options
author | Lars Knoll <lars.knoll@theqtcompany.com> | 2014-10-30 22:30:01 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2014-10-31 15:42:42 +0100 |
commit | 0704d2be63b484cb579c1507223db3f914b1338a (patch) | |
tree | 66d4e616545d7f576125e85cc108c7e2988cecdd /src/qml/qml/qqmltypewrapper.cpp | |
parent | e67948823d6810c2de784859da52a261bf80b550 (diff) |
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 <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml/qqmltypewrapper.cpp')
-rw-r--r-- | src/qml/qml/qqmltypewrapper.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp index 627b701512..d8f282c030 100644 --- a/src/qml/qml/qqmltypewrapper.cpp +++ b/src/qml/qml/qqmltypewrapper.cpp @@ -125,13 +125,12 @@ ReturnedValue QmlTypeWrapper::create(QV8Engine *v8, QObject *o, QQmlTypeNameCach ReturnedValue QmlTypeWrapper::get(Managed *m, String *name, bool *hasProperty) { + Q_ASSERT(m->as<QmlTypeWrapper>()); + QV4::ExecutionEngine *v4 = m->engine(); QV4::Scope scope(v4); - Scoped<QmlTypeWrapper> w(scope, m->as<QmlTypeWrapper>()); - if (!w) - return v4->currentContext()->throwTypeError(); - + Scoped<QmlTypeWrapper> w(scope, static_cast<QmlTypeWrapper *>(m)); if (hasProperty) *hasProperty = true; @@ -235,14 +234,11 @@ ReturnedValue QmlTypeWrapper::get(Managed *m, String *name, bool *hasProperty) void QmlTypeWrapper::put(Managed *m, String *name, const ValueRef value) { - QmlTypeWrapper *w = m->as<QmlTypeWrapper>(); + Q_ASSERT(m->as<QmlTypeWrapper>()); + QmlTypeWrapper *w = static_cast<QmlTypeWrapper *>(m); QV4::ExecutionEngine *v4 = m->engine(); if (v4->hasException) return; - if (!w) { - v4->currentContext()->throwTypeError(); - return; - } QV4::Scope scope(v4); QV8Engine *v8engine = v4->v8Engine; @@ -290,8 +286,9 @@ void QmlTypeWrapper::destroy(Managed *that) bool QmlTypeWrapper::isEqualTo(Managed *a, Managed *b) { - QV4::QmlTypeWrapper *qmlTypeWrapperA = a->asObject()->as<QV4::QmlTypeWrapper>(); - if (QV4::QmlTypeWrapper *qmlTypeWrapperB = b->asObject()->as<QV4::QmlTypeWrapper>()) + Q_ASSERT(a->as<QV4::QmlTypeWrapper>()); + QV4::QmlTypeWrapper *qmlTypeWrapperA = static_cast<QV4::QmlTypeWrapper *>(a); + if (QV4::QmlTypeWrapper *qmlTypeWrapperB = b->as<QV4::QmlTypeWrapper>()) return qmlTypeWrapperA->toVariant() == qmlTypeWrapperB->toVariant(); else if (QV4::QObjectWrapper *qobjectWrapper = b->as<QV4::QObjectWrapper>()) return qmlTypeWrapperA->toVariant().value<QObject*>() == qobjectWrapper->object(); |