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/quick/items/context2d | |
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/quick/items/context2d')
-rw-r--r-- | src/quick/items/context2d/qquickcontext2d.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp index b1af6f10dd..0101e0edf4 100644 --- a/src/quick/items/context2d/qquickcontext2d.cpp +++ b/src/quick/items/context2d/qquickcontext2d.cpp @@ -3093,11 +3093,12 @@ QV4::ReturnedValue QQuickJSContext2DPixelData::proto_get_length(QV4::CallContext QV4::ReturnedValue QQuickJSContext2DPixelData::getIndexed(QV4::Managed *m, uint index, bool *hasProperty) { + Q_ASSERT(m->as<QQuickJSContext2DPixelData>()); QV4::ExecutionEngine *v4 = m->engine(); QV4::Scope scope(v4); - QV4::Scoped<QQuickJSContext2DPixelData> r(scope, m->as<QQuickJSContext2DPixelData>()); + QV4::Scoped<QQuickJSContext2DPixelData> r(scope, static_cast<QQuickJSContext2DPixelData *>(m)); - if (r && index < static_cast<quint32>(r->d()->image.width() * r->d()->image.height() * 4)) { + if (index < static_cast<quint32>(r->d()->image.width() * r->d()->image.height() * 4)) { if (hasProperty) *hasProperty = true; const quint32 w = r->d()->image.width(); @@ -3123,16 +3124,13 @@ QV4::ReturnedValue QQuickJSContext2DPixelData::getIndexed(QV4::Managed *m, uint void QQuickJSContext2DPixelData::putIndexed(QV4::Managed *m, uint index, const QV4::ValueRef value) { + Q_ASSERT(m->as<QQuickJSContext2DPixelData>()); QV4::ExecutionEngine *v4 = m->engine(); QV4::Scope scope(v4); if (scope.hasException()) return; - QV4::Scoped<QQuickJSContext2DPixelData> r(scope, m->as<QQuickJSContext2DPixelData>()); - if (!r) { - scope.engine->currentContext()->throwTypeError(); - return; - } + QV4::Scoped<QQuickJSContext2DPixelData> r(scope, static_cast<QQuickJSContext2DPixelData *>(m)); const int v = value->toInt32(); if (r && index < static_cast<quint32>(r->d()->image.width() * r->d()->image.height() * 4) && v >= 0 && v <= 255) { |