aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmllistwrapper.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@theqtcompany.com>2014-10-30 22:30:01 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2014-10-31 15:42:42 +0100
commit0704d2be63b484cb579c1507223db3f914b1338a (patch)
tree66d4e616545d7f576125e85cc108c7e2988cecdd /src/qml/qml/qqmllistwrapper.cpp
parente67948823d6810c2de784859da52a261bf80b550 (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/qqmllistwrapper.cpp')
-rw-r--r--src/qml/qml/qqmllistwrapper.cpp24
1 files changed, 10 insertions, 14 deletions
diff --git a/src/qml/qml/qqmllistwrapper.cpp b/src/qml/qml/qqmllistwrapper.cpp
index 9a51767ef1..13e5e49b55 100644
--- a/src/qml/qml/qqmllistwrapper.cpp
+++ b/src/qml/qml/qqmllistwrapper.cpp
@@ -98,10 +98,9 @@ QVariant QmlListWrapper::toVariant() const
ReturnedValue QmlListWrapper::get(Managed *m, String *name, bool *hasProperty)
{
+ Q_ASSERT(m->as<QmlListWrapper>());
QV4::ExecutionEngine *v4 = m->engine();
- QmlListWrapper *w = m->as<QmlListWrapper>();
- if (!w)
- return v4->currentContext()->throwTypeError();
+ QmlListWrapper *w = static_cast<QmlListWrapper *>(m);
if (name->equals(v4->id_length) && !w->d()->object.isNull()) {
quint32 count = w->d()->property.count ? w->d()->property.count(&w->d()->property) : 0;
@@ -119,19 +118,15 @@ ReturnedValue QmlListWrapper::getIndexed(Managed *m, uint index, bool *hasProper
{
Q_UNUSED(hasProperty);
- QV4::ExecutionEngine *e = m->engine();
- QmlListWrapper *w = m->as<QmlListWrapper>();
- if (!w) {
- if (hasProperty)
- *hasProperty = false;
- return e->currentContext()->throwTypeError();
- }
+ Q_ASSERT(m->as<QmlListWrapper>());
+ QV4::ExecutionEngine *v4 = m->engine();
+ QmlListWrapper *w = static_cast<QmlListWrapper *>(m);
quint32 count = w->d()->property.count ? w->d()->property.count(&w->d()->property) : 0;
if (index < count && w->d()->property.at) {
if (hasProperty)
*hasProperty = true;
- return QV4::QObjectWrapper::wrap(e, w->d()->property.at(&w->d()->property, index));
+ return QV4::QObjectWrapper::wrap(v4, w->d()->property.at(&w->d()->property, index));
}
if (hasProperty)
@@ -149,15 +144,16 @@ void QmlListWrapper::put(Managed *m, String *name, const ValueRef value)
void QmlListWrapper::destroy(Managed *that)
{
- QmlListWrapper *w = that->as<QmlListWrapper>();
- w->d()->~Data();
+ Q_ASSERT(that->as<QmlListWrapper>());
+ static_cast<QmlListWrapper *>(that)->d()->~Data();
}
void QmlListWrapper::advanceIterator(Managed *m, ObjectIterator *it, String *&name, uint *index, Property *p, PropertyAttributes *attrs)
{
name = (String *)0;
*index = UINT_MAX;
- QmlListWrapper *w = m->as<QmlListWrapper>();
+ Q_ASSERT(m->as<QmlListWrapper>());
+ QmlListWrapper *w = static_cast<QmlListWrapper *>(m);
quint32 count = w->d()->property.count ? w->d()->property.count(&w->d()->property) : 0;
if (it->arrayIndex < count) {
*index = it->arrayIndex;