From 5f83e6dfe698d65a0c145ccfd09c9f00609311ca Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Wed, 8 Feb 2017 22:57:11 +0100 Subject: Object: Allow put and putIndexed to return success or failure Some parts of the ES6 (and even ES5!) spec specifically require handling of a property write failure. This will be introduced in followup changes, as it's going to be rather more involved than this. Change-Id: Ie482493fcf4780df0e23619650a856421d20bd55 Reviewed-by: Simon Hausmann --- src/quick/items/context2d/qquickcontext2d.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/quick') diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp index b0c1d50907..95fa0c530e 100644 --- a/src/quick/items/context2d/qquickcontext2d.cpp +++ b/src/quick/items/context2d/qquickcontext2d.cpp @@ -901,7 +901,7 @@ struct QQuickJSContext2DPixelData : public QV4::Object V4_NEEDS_DESTROY static QV4::ReturnedValue getIndexed(const QV4::Managed *m, uint index, bool *hasProperty); - static void putIndexed(QV4::Managed *m, uint index, const QV4::Value &value); + static bool putIndexed(QV4::Managed *m, uint index, const QV4::Value &value); static void proto_get_length(const QV4::BuiltinFunction *, QV4::Scope &scope, QV4::CallData *callData); }; @@ -3077,13 +3077,13 @@ QV4::ReturnedValue QQuickJSContext2DPixelData::getIndexed(const QV4::Managed *m, return QV4::Encode::undefined(); } -void QQuickJSContext2DPixelData::putIndexed(QV4::Managed *m, uint index, const QV4::Value &value) +bool QQuickJSContext2DPixelData::putIndexed(QV4::Managed *m, uint index, const QV4::Value &value) { Q_ASSERT(m->as()); QV4::ExecutionEngine *v4 = static_cast(m)->engine(); QV4::Scope scope(v4); if (scope.hasException()) - return; + return false; QV4::Scoped r(scope, static_cast(m)); @@ -3109,7 +3109,10 @@ void QQuickJSContext2DPixelData::putIndexed(QV4::Managed *m, uint index, const Q *pixel = qRgba(qRed(*pixel), qGreen(*pixel), qBlue(*pixel), v); break; } + return true; } + + return false; } /*! \qmlmethod CanvasImageData QtQuick::Context2D::createImageData(real sw, real sh) -- cgit v1.2.3