diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-09-18 16:36:02 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-22 01:06:20 +0200 |
commit | df5edd28bc4258b89d9d5ffdddf837f339a17aad (patch) | |
tree | 2a5939d5e3c49928aadf43337832d3ef5a58df08 /src/quick/items | |
parent | 700ba1bcb39e082049c96fafdfaccfe5d83cd77e (diff) |
convert Managed::put() API to be GC safe
Change-Id: I09198ce372fa545372db389fac26828d21ad5731
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/quick/items')
-rw-r--r-- | src/quick/items/context2d/qquickcontext2d.cpp | 3 | ||||
-rw-r--r-- | src/quick/items/qquickitem.cpp | 30 |
2 files changed, 20 insertions, 13 deletions
diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp index 1dd4e950c6..2e0657d6c1 100644 --- a/src/quick/items/context2d/qquickcontext2d.cpp +++ b/src/quick/items/context2d/qquickcontext2d.cpp @@ -2866,7 +2866,8 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_measureText(QV4::SimpleCal QFontMetrics fm(r->context->state.font); uint width = fm.width(ctx->arguments[0].toQStringNoThrow()); QV4::Scoped<QV4::Object> tm(scope, ctx->engine->newObject()); - tm->put(ctx->engine->newIdentifier(QStringLiteral("width")), QV4::Value::fromDouble(width)); + tm->put(QV4::ScopedString(scope, ctx->engine->newIdentifier(QStringLiteral("width"))), + QV4::ScopedValue(scope, QV4::Value::fromDouble(width))); return tm.asReturnedValue(); } return QV4::Encode::undefined(); diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 341339e7b9..1585b1e6dd 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -3882,6 +3882,9 @@ void QQuickItem::mapFromItem(QQmlV4Function *args) const QV4::Scoped<QV4::Object> rv(scope, v4->newObject()); args->setReturnValue(rv.asValue()); + QV4::ScopedString s(scope); + QV4::ScopedValue v(scope); + qreal x = (args->length() > 1) ? (*args)[1].asDouble() : 0; qreal y = (args->length() > 2) ? (*args)[2].asDouble() : 0; @@ -3891,15 +3894,15 @@ void QQuickItem::mapFromItem(QQmlV4Function *args) const QRectF r = mapRectFromItem(itemObj, QRectF(x, y, w, h)); - rv->put(v4->newString(QStringLiteral("x")), QV4::Value::fromDouble(r.x())); - rv->put(v4->newString(QStringLiteral("y")), QV4::Value::fromDouble(r.y())); - rv->put(v4->newString(QStringLiteral("width")), QV4::Value::fromDouble(r.width())); - rv->put(v4->newString(QStringLiteral("height")), QV4::Value::fromDouble(r.height())); + rv->put((s = v4->newString(QStringLiteral("x"))), (v = QV4::Value::fromDouble(r.x()))); + rv->put((s = v4->newString(QStringLiteral("y"))), (v = QV4::Value::fromDouble(r.y()))); + rv->put((s = v4->newString(QStringLiteral("width"))), (v = QV4::Value::fromDouble(r.width()))); + rv->put((s = v4->newString(QStringLiteral("height"))), (v = QV4::Value::fromDouble(r.height()))); } else { QPointF p = mapFromItem(itemObj, QPointF(x, y)); - rv->put(v4->newString(QStringLiteral("x")), QV4::Value::fromDouble(p.x())); - rv->put(v4->newString(QStringLiteral("y")), QV4::Value::fromDouble(p.y())); + rv->put((s = v4->newString(QStringLiteral("x"))), (v = QV4::Value::fromDouble(p.x()))); + rv->put((s = v4->newString(QStringLiteral("y"))), (v = QV4::Value::fromDouble(p.y()))); } } } @@ -3960,21 +3963,24 @@ void QQuickItem::mapToItem(QQmlV4Function *args) const qreal x = (args->length() > 1) ? (*args)[1].asDouble() : 0; qreal y = (args->length() > 2) ? (*args)[2].asDouble() : 0; + QV4::ScopedString s(scope); + QV4::ScopedValue v(scope); + if (args->length() > 3) { qreal w = (*args)[3].asDouble(); qreal h = (args->length() > 4) ? (*args)[4].asDouble() : 0; QRectF r = mapRectToItem(itemObj, QRectF(x, y, w, h)); - rv->put(v4->newString(QStringLiteral("x")), QV4::Value::fromDouble(r.x())); - rv->put(v4->newString(QStringLiteral("y")), QV4::Value::fromDouble(r.y())); - rv->put(v4->newString(QStringLiteral("width")), QV4::Value::fromDouble(r.width())); - rv->put(v4->newString(QStringLiteral("height")), QV4::Value::fromDouble(r.height())); + rv->put((s = v4->newString(QStringLiteral("x"))), (v = QV4::Value::fromDouble(r.x()))); + rv->put((s = v4->newString(QStringLiteral("y"))), (v = QV4::Value::fromDouble(r.y()))); + rv->put((s = v4->newString(QStringLiteral("width"))), (v = QV4::Value::fromDouble(r.width()))); + rv->put((s = v4->newString(QStringLiteral("height"))), (v = QV4::Value::fromDouble(r.height()))); } else { QPointF p = mapToItem(itemObj, QPointF(x, y)); - rv->put(v4->newString(QStringLiteral("x")), QV4::Value::fromDouble(p.x())); - rv->put(v4->newString(QStringLiteral("y")), QV4::Value::fromDouble(p.y())); + rv->put((s = v4->newString(QStringLiteral("x"))), (v = QV4::Value::fromDouble(p.x()))); + rv->put((s = v4->newString(QStringLiteral("y"))), (v = QV4::Value::fromDouble(p.y()))); } } } |