diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-09-13 21:54:21 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-18 13:14:10 +0200 |
commit | e4e90923c93adfafb23c81be7359e8df2a500b4f (patch) | |
tree | 36be927b72606c4f37326089ff3c6261f484c92b /src | |
parent | 9dcc12d52343960400192c817f54a16f7e1f8247 (diff) |
Convert some methods to use Returned<>
Change-Id: I631606cb5ab3b35b72104e70092a5200dd235fbc
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/localstorage/plugin.cpp | 22 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4context.cpp | 71 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4context_p.h | 5 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 18 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine_p.h | 8 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4errorobject.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4lookup.cpp | 4 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4scopedvalue_p.h | 9 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4script.cpp | 7 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4string.cpp | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4stringobject.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlcontextwrapper.cpp | 6 | ||||
-rw-r--r-- | src/qml/qml/qqmlvaluetypewrapper.cpp | 10 | ||||
-rw-r--r-- | src/qml/qml/qqmlxmlhttprequest.cpp | 27 | ||||
-rw-r--r-- | src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 23 | ||||
-rw-r--r-- | src/qml/qml/v8/qv4domerrors_p.h | 6 | ||||
-rw-r--r-- | src/quick/items/context2d/qquickcontext2d.cpp | 42 |
18 files changed, 190 insertions, 80 deletions
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index 14c49a08e1..246ddd96c5 100644 --- a/src/imports/localstorage/plugin.cpp +++ b/src/imports/localstorage/plugin.cpp @@ -65,14 +65,14 @@ using namespace QV4; #define V4THROW_SQL(error, desc) { \ - Value v = Value::fromString(ctx, desc); \ - Object *ex = ctx->engine->newErrorObject(v); \ + QV4::Scoped<String> v(scope, Value::fromString(ctx, desc)); \ + QV4::Scoped<Object> ex(scope, ctx->engine->newErrorObject(v.asValue())); \ ex->put(ctx->engine->newIdentifier(QStringLiteral("code")), Value::fromInt32(error)); \ - ctx->throwError(Value::fromObject(ex)); \ + ctx->throwError(ex); \ } #define V4THROW_REFERENCE(string) { \ - Value v = Value::fromString(ctx, string); \ + QV4::Scoped<String> v(scope, Value::fromString(ctx, string)); \ ctx->throwReferenceError(v); \ } @@ -126,6 +126,8 @@ DEFINE_MANAGED_VTABLE(QQmlSqlDatabaseWrapper); static ReturnedValue qmlsqldatabase_version(SimpleCallContext *ctx) { + QV4::Scope scope(ctx); + QQmlSqlDatabaseWrapper *r = ctx->thisObject.as<QQmlSqlDatabaseWrapper>(); if (!r || r->type != QQmlSqlDatabaseWrapper::Database) V4THROW_REFERENCE("Not a SQLDatabase object"); @@ -135,6 +137,8 @@ static ReturnedValue qmlsqldatabase_version(SimpleCallContext *ctx) static ReturnedValue qmlsqldatabase_rows_length(SimpleCallContext *ctx) { + QV4::Scope scope(ctx); + QQmlSqlDatabaseWrapper *r = ctx->thisObject.as<QQmlSqlDatabaseWrapper>(); if (!r || r->type != QQmlSqlDatabaseWrapper::Rows) V4THROW_REFERENCE("Not a SQLDatabase::Rows object"); @@ -153,6 +157,8 @@ static ReturnedValue qmlsqldatabase_rows_length(SimpleCallContext *ctx) static ReturnedValue qmlsqldatabase_rows_forwardOnly(SimpleCallContext *ctx) { + QV4::Scope scope(ctx); + QQmlSqlDatabaseWrapper *r = ctx->thisObject.as<QQmlSqlDatabaseWrapper>(); if (!r || r->type != QQmlSqlDatabaseWrapper::Rows) V4THROW_REFERENCE("Not a SQLDatabase::Rows object"); @@ -161,6 +167,8 @@ static ReturnedValue qmlsqldatabase_rows_forwardOnly(SimpleCallContext *ctx) static ReturnedValue qmlsqldatabase_rows_setForwardOnly(SimpleCallContext *ctx) { + QV4::Scope scope(ctx); + QQmlSqlDatabaseWrapper *r = ctx->thisObject.as<QQmlSqlDatabaseWrapper>(); if (!r || r->type != QQmlSqlDatabaseWrapper::Rows) V4THROW_REFERENCE("Not a SQLDatabase::Rows object"); @@ -228,6 +236,7 @@ ReturnedValue QQmlSqlDatabaseWrapper::getIndexed(Managed *m, uint index, bool *h static ReturnedValue qmlsqldatabase_rows_item(SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQmlSqlDatabaseWrapper *r = ctx->thisObject.as<QQmlSqlDatabaseWrapper>(); if (!r || r->type != QQmlSqlDatabaseWrapper::Rows) V4THROW_REFERENCE("Not a SQLDatabase::Rows object"); @@ -237,6 +246,7 @@ static ReturnedValue qmlsqldatabase_rows_item(SimpleCallContext *ctx) static ReturnedValue qmlsqldatabase_executeSql(SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQmlSqlDatabaseWrapper *r = ctx->thisObject.as<QQmlSqlDatabaseWrapper>(); if (!r || r->type != QQmlSqlDatabaseWrapper::Query) V4THROW_REFERENCE("Not a SQLDatabase::Query object"); @@ -257,7 +267,6 @@ static ReturnedValue qmlsqldatabase_executeSql(SimpleCallContext *ctx) QSqlQuery query(db); bool err = false; - Scope scope(QV8Engine::getV4(engine)); ScopedValue result(scope, Value::undefinedValue()); if (query.prepare(sql)) { @@ -377,11 +386,11 @@ static ReturnedValue qmlsqldatabase_changeVersion(SimpleCallContext *ctx) static ReturnedValue qmlsqldatabase_transaction_shared(SimpleCallContext *ctx, bool readOnly) { + QV4::Scope scope(ctx); QQmlSqlDatabaseWrapper *r = ctx->thisObject.as<QQmlSqlDatabaseWrapper>(); if (!r || r->type != QQmlSqlDatabaseWrapper::Database) V4THROW_REFERENCE("Not a SQLDatabase object"); - Scope scope(ctx); QV8Engine *engine = ctx->engine->v8Engine; FunctionObject *callback = ctx->argumentCount ? ctx->arguments[0].asFunctionObject() : 0; @@ -624,6 +633,7 @@ void QQuickLocalStorage::openDatabaseSync(QQmlV4Function *args) #ifndef QT_NO_SETTINGS QV8Engine *engine = args->engine(); ExecutionContext *ctx = QV8Engine::getV4(engine)->current; + QV4::Scope scope(ctx); if (engine->engine()->offlineStoragePath().isEmpty()) V4THROW_SQL(SQLEXCEPTION_DATABASE_ERR, QQmlEngine::tr("SQL: can't create database, offline storage is disabled.")); diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index 1a1efc0b4c..56701457e4 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -363,6 +363,7 @@ void ExecutionContext::mark() void ExecutionContext::setProperty(String *name, const Value& value) { + Scope scope(this); for (ExecutionContext *ctx = this; ctx; ctx = ctx->outer) { if (ctx->type == Type_WithContext) { Object *w = static_cast<WithContext *>(ctx)->withObject; @@ -398,8 +399,10 @@ void ExecutionContext::setProperty(String *name, const Value& value) } } } - if (strictMode || name->isEqualTo(engine->id_this)) - throwReferenceError(Value::fromString(name)); + if (strictMode || name->isEqualTo(engine->id_this)) { + Scoped<String> n(scope, name); + throwReferenceError(n); + } engine->globalObject->put(name, value); } @@ -463,7 +466,8 @@ ReturnedValue ExecutionContext::getProperty(String *name) return v.asReturnedValue(); } } - throwReferenceError(Value::fromString(name)); + Scoped<String> n(scope, name); + throwReferenceError(n); return Value::undefinedValue().asReturnedValue(); } @@ -595,75 +599,92 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Object **base) return v.asReturnedValue(); } } - throwReferenceError(Value::fromString(name)); + Scoped<String> n(scope, name); + throwReferenceError(n); return Value::undefinedValue().asReturnedValue(); } -void ExecutionContext::throwError(const Value &value) +void ExecutionContext::throwError(const ValueRef value) { - Scope scope(this); - ScopedValue v(scope, value); - __qmljs_throw(this, v); + __qmljs_throw(this, value); } void ExecutionContext::throwError(const QString &message) { - Value v = Value::fromString(this, message); - throwError(Value::fromObject(engine->newErrorObject(v))); + Scope scope(this); + ScopedValue v(scope, Value::fromString(this, message)); + v = engine->newErrorObject(v); + throwError(v); } void ExecutionContext::throwSyntaxError(const QString &message, const QString &fileName, int line, int column) { - Object *error = engine->newSyntaxErrorObject(message, fileName, line, column); - throwError(Value::fromObject(error)); + Scope scope(this); + Scoped<Object> error(scope, engine->newSyntaxErrorObject(message, fileName, line, column)); + throwError(error); } void ExecutionContext::throwSyntaxError(const QString &message) { - Object *error = engine->newSyntaxErrorObject(message); - throwError(Value::fromObject(error)); + Scope scope(this); + Scoped<Object> error(scope, engine->newSyntaxErrorObject(message)); + throwError(error); } void ExecutionContext::throwTypeError() { - throwError(Value::fromObject(engine->newTypeErrorObject(QStringLiteral("Type error")))); + Scope scope(this); + Scoped<Object> error(scope, engine->newTypeErrorObject(QStringLiteral("Type error"))); + throwError(error); } void ExecutionContext::throwTypeError(const QString &message) { - throwError(Value::fromObject(engine->newTypeErrorObject(message))); + Scope scope(this); + Scoped<Object> error(scope, engine->newTypeErrorObject(message)); + throwError(error); } void ExecutionContext::throwUnimplemented(const QString &message) { - Value v = Value::fromString(this, QStringLiteral("Unimplemented ") + message); - throwError(Value::fromObject(engine->newErrorObject(v))); + Scope scope(this); + ScopedValue v(scope, Value::fromString(this, QStringLiteral("Unimplemented ") + message)); + v = engine->newErrorObject(v); + throwError(v); } -void ExecutionContext::throwReferenceError(Value value) +void ExecutionContext::throwReferenceError(const ValueRef value) { - String *s = value.toString(this); + Scope scope(this); + Scoped<String> s(scope, value->toString(this)); QString msg = s->toQString() + QStringLiteral(" is not defined"); - throwError(Value::fromObject(engine->newReferenceErrorObject(msg))); + Scoped<Object> error(scope, engine->newReferenceErrorObject(msg)); + throwError(error); } void ExecutionContext::throwReferenceError(const QString &message, const QString &fileName, int line, int column) { + Scope scope(this); QString msg = message + QStringLiteral(" is not defined"); - throwError(Value::fromObject(engine->newReferenceErrorObject(msg, fileName, line, column))); + Scoped<Object> error(scope, engine->newReferenceErrorObject(msg, fileName, line, column)); + throwError(error); } void ExecutionContext::throwRangeError(Value value) { - String *s = value.toString(this); + Scope scope(this); + Scoped<String> s(scope, value.toString(this)); QString msg = s->toQString() + QStringLiteral(" out of range"); - throwError(Value::fromObject(engine->newRangeErrorObject(msg))); + Scoped<Object> error(scope, engine->newRangeErrorObject(msg)); + throwError(error); } void ExecutionContext::throwURIError(Value msg) { - throwError(Value::fromObject(engine->newURIErrorObject(msg))); + Scope scope(this); + Scoped<Object> error(scope, engine->newURIErrorObject(msg)); + throwError(error); } void SimpleCallContext::initSimpleCallContext(ExecutionEngine *engine) diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h index 8ebffea981..0c3b189401 100644 --- a/src/qml/jsruntime/qv4context_p.h +++ b/src/qml/jsruntime/qv4context_p.h @@ -54,6 +54,7 @@ struct ExecutionEngine; struct DeclarativeEnvironment; struct Lookup; struct Function; +struct ValueRef; namespace CompiledData { struct CompilationUnit; @@ -129,13 +130,13 @@ struct Q_QML_EXPORT ExecutionContext void createMutableBinding(String *name, bool deletable); - void Q_NORETURN throwError(const Value &value); + void Q_NORETURN throwError(const QV4::ValueRef value); void Q_NORETURN throwError(const QString &message); void Q_NORETURN throwSyntaxError(const QString &message); void Q_NORETURN throwSyntaxError(const QString &message, const QString &fileName, int line, int column); void Q_NORETURN throwTypeError(); void Q_NORETURN throwTypeError(const QString &message); - void Q_NORETURN throwReferenceError(Value value); + void Q_NORETURN throwReferenceError(const ValueRef value); void Q_NORETURN throwReferenceError(const QString &value, const QString &fileName, int line, int column); void Q_NORETURN throwRangeError(Value value); void Q_NORETURN throwURIError(Value msg); diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 875ab84cf5..0187099f62 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -375,10 +375,10 @@ String *ExecutionEngine::newIdentifier(const QString &text) return identifierTable->insertString(text); } -Object *ExecutionEngine::newStringObject(const Value &value) +Returned<Object> *ExecutionEngine::newStringObject(const Value &value) { StringObject *object = new (memoryManager) StringObject(this, value); - return object; + return object->asReturned<Object>(); } Returned<Object> *ExecutionEngine::newNumberObject(const Value &value) @@ -455,20 +455,22 @@ Returned<RegExpObject> *ExecutionEngine::newRegExpObject(const QRegExp &re) return object->asReturned<RegExpObject>(); } -Object *ExecutionEngine::newErrorObject(const Value &value) +Returned<Object> *ExecutionEngine::newErrorObject(const Value &value) { ErrorObject *object = new (memoryManager) ErrorObject(errorClass, value); - return object; + return object->asReturned<Object>(); } -Object *ExecutionEngine::newSyntaxErrorObject(const QString &message) +Returned<Object> *ExecutionEngine::newSyntaxErrorObject(const QString &message) { - return new (memoryManager) SyntaxErrorObject(this, Value::fromString(this, message)); + Object *error = new (memoryManager) SyntaxErrorObject(this, Value::fromString(this, message)); + return error->asReturned<Object>(); } -Object *ExecutionEngine::newSyntaxErrorObject(const QString &message, const QString &fileName, int line, int column) +Returned<Object> *ExecutionEngine::newSyntaxErrorObject(const QString &message, const QString &fileName, int line, int column) { - return new (memoryManager) SyntaxErrorObject(this, message, fileName, line, column); + Object *error = new (memoryManager) SyntaxErrorObject(this, message, fileName, line, column); + return error->asReturned<Object>(); } diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index a59a837499..5ef7d08a4a 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -270,7 +270,7 @@ struct Q_QML_EXPORT ExecutionEngine String *newString(const QString &s); String *newIdentifier(const QString &text); - Object *newStringObject(const Value &value); + Returned<Object> *newStringObject(const Value &value); Returned<Object> *newNumberObject(const Value &value); Returned<Object> *newBooleanObject(const Value &value); @@ -285,9 +285,9 @@ struct Q_QML_EXPORT ExecutionEngine Returned<RegExpObject> *newRegExpObject(RegExp* re, bool global); Returned<RegExpObject> *newRegExpObject(const QRegExp &re); - Object *newErrorObject(const Value &value); - Object *newSyntaxErrorObject(const QString &message, const QString &fileName, int line, int column); - Object *newSyntaxErrorObject(const QString &message); + Returned<Object> *newErrorObject(const Value &value); + Returned<Object> *newSyntaxErrorObject(const QString &message, const QString &fileName, int line, int column); + Returned<Object> *newSyntaxErrorObject(const QString &message); Object *newReferenceErrorObject(const QString &message); Object *newReferenceErrorObject(const QString &message, const QString &fileName, int lineNumber, int columnNumber); Object *newTypeErrorObject(const QString &message); diff --git a/src/qml/jsruntime/qv4errorobject.cpp b/src/qml/jsruntime/qv4errorobject.cpp index 7c75d1162a..987d5083fa 100644 --- a/src/qml/jsruntime/qv4errorobject.cpp +++ b/src/qml/jsruntime/qv4errorobject.cpp @@ -242,7 +242,7 @@ ErrorCtor::ErrorCtor(ExecutionContext *scope, String *name) ReturnedValue ErrorCtor::construct(Managed *m, CallData *callData) { - return Value::fromObject(m->engine()->newErrorObject(callData->argc ? callData->args[0] : Value::undefinedValue())).asReturnedValue(); + return Encode(m->engine()->newErrorObject(callData->argc ? callData->args[0] : Value::undefinedValue())); } ReturnedValue ErrorCtor::call(Managed *that, CallData *callData) diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp index a4116b049e..a844a25008 100644 --- a/src/qml/jsruntime/qv4lookup.cpp +++ b/src/qml/jsruntime/qv4lookup.cpp @@ -334,7 +334,9 @@ ReturnedValue Lookup::globalGetterGeneric(Lookup *l, ExecutionContext *ctx) return o->getValue(p, attrs); } } - ctx->throwReferenceError(Value::fromString(l->name)); + Scope scope(ctx); + Scoped<String> n(scope, l->name); + ctx->throwReferenceError(n); } ReturnedValue Lookup::globalGetter0(Lookup *l, ExecutionContext *ctx) diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 7af8b21cc5..d98087b6a4 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -607,7 +607,7 @@ Returned<Object> *__qmljs_convert_to_object(ExecutionContext *ctx, const ValueRe case Value::Boolean_Type: return ctx->engine->newBooleanObject(*value); case Value::String_Type: - return ctx->engine->newStringObject(*value)->asReturned<Object>(); + return ctx->engine->newStringObject(*value); break; case Value::Object_Type: Q_UNREACHABLE(); diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index eed49bfe1f..4bbd3303ee 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -142,7 +142,7 @@ struct ScopedValue ScopedValue(const Scope &scope, Returned<T> *t) { ptr = scope.engine->jsStackTop++; - ptr->val = T::toValue(t->getPointer()); + *ptr = T::toValue(t->getPointer()); #ifndef QT_NO_DEBUG ++scope.size; #endif @@ -159,8 +159,8 @@ struct ScopedValue } template<typename T> - ScopedValue &operator=(const Returned<T> *t) { - ptr->val = T::toValue(t->getPointer()); + ScopedValue &operator=(Returned<T> *t) { + *ptr = T::toValue(t->getPointer()); return *this; } @@ -331,6 +331,9 @@ struct ScopedCallData { struct ValueRef { ValueRef(const ScopedValue &v) : ptr(v.ptr) {} + template <typename T> + ValueRef(const Scoped<T> &v) + : ptr(v.ptr) {} ValueRef(const PersistentValue &v) : ptr(&v.d->value) {} ValueRef(PersistentValuePrivate *p) diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index e3c9505ab7..1834e28be6 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -153,6 +153,7 @@ void Script::parse() parsed = true; ExecutionEngine *v4 = scope->engine; + Scope valueScope(v4); MemoryManager::GCBlocker gcBlocker(v4->memoryManager); @@ -199,9 +200,11 @@ void Script::parse() compilationUnitHolder = Value::fromObject(new (v4->memoryManager) CompilationUnitHolder(v4, compilationUnit)); } - if (!vmFunction) + if (!vmFunction) { // ### FIX file/line number - v4->current->throwError(QV4::Value::fromObject(v4->newSyntaxErrorObject("Syntax error"))); + Scoped<Object> error(valueScope, v4->newSyntaxErrorObject("Syntax error")); + v4->current->throwError(error); + } } ReturnedValue Script::run() diff --git a/src/qml/jsruntime/qv4string.cpp b/src/qml/jsruntime/qv4string.cpp index 2b2eda7c8c..d0f3a196b7 100644 --- a/src/qml/jsruntime/qv4string.cpp +++ b/src/qml/jsruntime/qv4string.cpp @@ -173,15 +173,17 @@ ReturnedValue String::getIndexed(Managed *m, uint index, bool *hasProperty) void String::put(Managed *m, String *name, const Value &value) { + Scope scope(m->engine()); String *that = static_cast<String *>(m); - Object *o = that->engine()->newStringObject(Value::fromString(that)); + Scoped<Object> o(scope, that->engine()->newStringObject(Value::fromString(that))); o->put(name, value); } void String::putIndexed(Managed *m, uint index, const Value &value) { + Scope scope(m->engine()); String *that = static_cast<String *>(m); - Object *o = m->engine()->newStringObject(Value::fromString(that)); + Scoped<Object> o(scope, that->engine()->newStringObject(Value::fromString(that))); o->putIndexed(index, value); } diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index dfdb639d1e..2223432ec9 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -167,7 +167,7 @@ ReturnedValue StringCtor::construct(Managed *m, CallData *callData) value = Value::fromString(callData->args[0].toString(m->engine()->current)); else value = Value::fromString(m->engine()->current, QString()); - return Value::fromObject(m->engine()->newStringObject(value)).asReturnedValue(); + return Encode(m->engine()->newStringObject(value)); } ReturnedValue StringCtor::call(Managed *m, CallData *callData) diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp index 50d1f32c10..153743aa58 100644 --- a/src/qml/qml/qqmlcontextwrapper.cpp +++ b/src/qml/qml/qqmlcontextwrapper.cpp @@ -274,8 +274,9 @@ ReturnedValue QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty void QmlContextWrapper::put(Managed *m, String *name, const Value &value) { - QmlContextWrapper *wrapper = m->as<QmlContextWrapper>(); ExecutionEngine *v4 = m->engine(); + QV4::Scope scope(v4); + QV4::Scoped<QmlContextWrapper> wrapper(scope, m->as<QmlContextWrapper>()); if (!wrapper) v4->current->throwTypeError(); @@ -283,7 +284,8 @@ void QmlContextWrapper::put(Managed *m, String *name, const Value &value) if (wrapper && wrapper->readOnly) { QString error = QLatin1String("Invalid write to global property \"") + name->toQString() + QLatin1Char('"'); - v4->current->throwError(Value::fromString(v4->current->engine->newString(error))); + Scoped<String> e(scope, v4->current->engine->newString(error)); + v4->current->throwError(e); } Object::put(m, name, value); diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index 88704d58b3..f89ce15a57 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -327,14 +327,15 @@ ReturnedValue QmlValueTypeWrapper::get(Managed *m, String *name, bool *hasProper void QmlValueTypeWrapper::put(Managed *m, String *name, const Value &value) { - QmlValueTypeWrapper *r = m->as<QmlValueTypeWrapper>(); ExecutionEngine *v4 = m->engine(); + Scope scope(v4); + Scoped<QmlValueTypeWrapper> r(scope, m->as<QmlValueTypeWrapper>()); if (!r) v4->current->throwTypeError(); QByteArray propName = name->toQString().toUtf8(); if (r->objectType == QmlValueTypeWrapper::Reference) { - QmlValueTypeReference *reference = static_cast<QmlValueTypeReference *>(r); + QmlValueTypeReference *reference = static_cast<QmlValueTypeReference *>(r.getPointer()); QMetaProperty writebackProperty = reference->object->metaObject()->property(reference->property); if (!reference->object || !writebackProperty.isWritable() || !readReferenceValue(reference)) @@ -353,7 +354,8 @@ void QmlValueTypeWrapper::put(Managed *m, String *name, const Value &value) if (!f->bindingKeyFlag) { // assigning a JS function to a non-var-property is not allowed. QString error = QLatin1String("Cannot assign JavaScript function to value-type property"); - v4->current->throwError(r->v8->toString(error)); + Scoped<String> e(scope, r->v8->toString(error)); + v4->current->throwError(e); } QQmlContextData *context = r->v8->callingContext(); @@ -400,7 +402,7 @@ void QmlValueTypeWrapper::put(Managed *m, String *name, const Value &value) } else { Q_ASSERT(r->objectType == QmlValueTypeWrapper::Copy); - QmlValueTypeCopy *copy = static_cast<QmlValueTypeCopy *>(r); + QmlValueTypeCopy *copy = static_cast<QmlValueTypeCopy *>(r.getPointer()); int index = r->type->metaObject()->indexOfProperty(propName.constData()); if (index == -1) diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index b7447aee07..dc98bd176e 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -70,8 +70,10 @@ using namespace QV4; #ifndef QT_NO_XMLSTREAMREADER -#define V4THROW_REFERENCE(string) \ - ctx->throwError(Value::fromObject(ctx->engine->newReferenceErrorObject(QStringLiteral(string)))) +#define V4THROW_REFERENCE(string) { \ + Scoped<Object> error(scope, ctx->engine->newReferenceErrorObject(QStringLiteral(string))); \ + ctx->throwError(error); \ + } QT_BEGIN_NAMESPACE @@ -1658,6 +1660,7 @@ void QQmlXMLHttpRequestCtor::setupProto() // XMLHttpRequest methods ReturnedValue QQmlXMLHttpRequestCtor::method_open(SimpleCallContext *ctx) { + Scope scope(ctx); QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>(); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); @@ -1706,6 +1709,8 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_open(SimpleCallContext *ctx) ReturnedValue QQmlXMLHttpRequestCtor::method_setRequestHeader(SimpleCallContext *ctx) { + Scope scope(ctx); + QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>(); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); @@ -1752,6 +1757,8 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_setRequestHeader(SimpleCallContext ReturnedValue QQmlXMLHttpRequestCtor::method_send(SimpleCallContext *ctx) { + Scope scope(ctx); + QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>(); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); @@ -1772,6 +1779,8 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_send(SimpleCallContext *ctx) ReturnedValue QQmlXMLHttpRequestCtor::method_abort(SimpleCallContext *ctx) { + Scope scope(ctx); + QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>(); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); @@ -1782,6 +1791,8 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_abort(SimpleCallContext *ctx) ReturnedValue QQmlXMLHttpRequestCtor::method_getResponseHeader(SimpleCallContext *ctx) { + Scope scope(ctx); + QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>(); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); @@ -1802,6 +1813,8 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_getResponseHeader(SimpleCallContext ReturnedValue QQmlXMLHttpRequestCtor::method_getAllResponseHeaders(SimpleCallContext *ctx) { + Scope scope(ctx); + QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>(); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); @@ -1823,6 +1836,8 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_getAllResponseHeaders(SimpleCallCon // XMLHttpRequest properties ReturnedValue QQmlXMLHttpRequestCtor::method_get_readyState(SimpleCallContext *ctx) { + Scope scope(ctx); + QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>(); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); @@ -1833,6 +1848,8 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_readyState(SimpleCallContext *c ReturnedValue QQmlXMLHttpRequestCtor::method_get_status(SimpleCallContext *ctx) { + Scope scope(ctx); + QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>(); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); @@ -1850,6 +1867,8 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_status(SimpleCallContext *ctx) ReturnedValue QQmlXMLHttpRequestCtor::method_get_statusText(SimpleCallContext *ctx) { + Scope scope(ctx); + QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>(); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); @@ -1869,6 +1888,8 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_statusText(SimpleCallContext *c ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseText(SimpleCallContext *ctx) { + Scope scope(ctx); + QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>(); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); @@ -1885,6 +1906,8 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseText(SimpleCallContext ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseXML(SimpleCallContext *ctx) { + Scope scope(ctx); + QQmlXMLHttpRequestWrapper *w = ctx->thisObject.as<QQmlXMLHttpRequestWrapper>(); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 2a75bf9834..6389ad2715 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -949,29 +949,30 @@ See \l {Dynamic QML Object Creation from JavaScript} for more information on usi */ ReturnedValue QtObject::method_createQmlObject(SimpleCallContext *ctx) { + Scope scope(ctx); if (ctx->argumentCount < 2 || ctx->argumentCount > 3) V4THROW_ERROR("Qt.createQmlObject(): Invalid arguments"); struct Error { - static Value create(QV8Engine *engine, const QList<QQmlError> &errors) { + static ReturnedValue create(QV4::ExecutionEngine *v4, const QList<QQmlError> &errors) { + Scope scope(v4); QString errorstr = QLatin1String("Qt.createQmlObject(): failed to create object: "); - QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine); - QV4::ArrayObject *qmlerrors = v4->newArrayObject(); + QV4::Scoped<ArrayObject> qmlerrors(scope, v4->newArrayObject()); for (int ii = 0; ii < errors.count(); ++ii) { const QQmlError &error = errors.at(ii); errorstr += QLatin1String("\n ") + error.toString(); QV4::Object *qmlerror = v4->newObject(); qmlerror->put(v4->newString("lineNumber"), QV4::Value::fromInt32(error.line())); qmlerror->put(v4->newString("columnNumber"), QV4::Value::fromInt32(error.column())); - qmlerror->put(v4->newString("fileName"), engine->toString(error.url().toString())); - qmlerror->put(v4->newString("message"), engine->toString(error.description())); + qmlerror->put(v4->newString("fileName"), Value::fromString(v4->newString(error.url().toString()))); + qmlerror->put(v4->newString("message"), Value::fromString(v4->newString(error.description()))); qmlerrors->putIndexed(ii, QV4::Value::fromObject(qmlerror)); } - QV4::Object *errorObject = v4->newErrorObject(engine->toString(errorstr)); - errorObject->put(v4->newString("qmlErrors"), Value::fromObject(qmlerrors)); - return Value::fromObject(errorObject); + Scoped<Object> errorObject(scope, v4->newErrorObject(Value::fromString(v4->newString(errorstr)))); + errorObject->put(v4->newString("qmlErrors"), qmlerrors.asValue()); + return errorObject.asReturnedValue(); } }; @@ -1009,7 +1010,8 @@ ReturnedValue QtObject::method_createQmlObject(SimpleCallContext *ctx) component.setData(qml.toUtf8(), url); if (component.isError()) { - ctx->throwError(Error::create(v8engine, component.errors())); + ScopedValue v(scope, Error::create(ctx->engine, component.errors())); + ctx->throwError(v); return QV4::Encode::undefined(); } @@ -1033,7 +1035,8 @@ ReturnedValue QtObject::method_createQmlObject(SimpleCallContext *ctx) component.completeCreate(); if (component.isError()) { - ctx->throwError(Error::create(v8engine, component.errors())); + ScopedValue v(scope, Error::create(ctx->engine, component.errors())); + ctx->throwError(v); return QV4::Encode::undefined(); } diff --git a/src/qml/qml/v8/qv4domerrors_p.h b/src/qml/qml/v8/qv4domerrors_p.h index ed38886e15..ce6fb9edea 100644 --- a/src/qml/qml/v8/qv4domerrors_p.h +++ b/src/qml/qml/v8/qv4domerrors_p.h @@ -77,10 +77,10 @@ QT_BEGIN_NAMESPACE #define DOMEXCEPTION_TYPE_MISMATCH_ERR 17 #define V4THROW_DOM(error, string) { \ - QV4::Value v = QV4::Value::fromString(ctx, QStringLiteral(string)); \ - QV4::Object *ex = ctx->engine->newErrorObject(v); \ + QV4::ScopedValue v(scope, QV4::Value::fromString(ctx, QStringLiteral(string))); \ + QV4::Scoped<Object> ex(scope, ctx->engine->newErrorObject(v)); \ ex->put(ctx->engine->newIdentifier(QStringLiteral("code")), QV4::Value::fromInt32(error)); \ - ctx->throwError(QV4::Value::fromObject(ex)); \ + ctx->throwError(ex); \ } namespace QV4 { diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp index bc8e49797d..3a84404d66 100644 --- a/src/quick/items/context2d/qquickcontext2d.cpp +++ b/src/quick/items/context2d/qquickcontext2d.cpp @@ -1496,6 +1496,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_strokeStyle(QV4::SimpleCallCont QV4::ReturnedValue QQuickJSContext2DPrototype::method_createLinearGradient(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT(r) @@ -1541,6 +1542,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createLinearGradient(QV4:: QV4::ReturnedValue QQuickJSContext2DPrototype::method_createRadialGradient(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT(r) @@ -1594,6 +1596,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createRadialGradient(QV4:: QV4::ReturnedValue QQuickJSContext2DPrototype::method_createConicalGradient(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT(r) @@ -2097,6 +2100,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_strokeRect(QV4::SimpleCall */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_arc(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT(r) @@ -2147,6 +2151,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_arc(QV4::SimpleCallContext */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_arcTo(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT(r) @@ -2173,6 +2178,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_arcTo(QV4::SimpleCallConte */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_beginPath(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT(r) @@ -2203,6 +2209,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_beginPath(QV4::SimpleCallC */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_bezierCurveTo(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT(r) @@ -2250,6 +2257,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_bezierCurveTo(QV4::SimpleC */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_clip(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT(r) @@ -2266,6 +2274,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_clip(QV4::SimpleCallContex */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_closePath(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT(r) @@ -2286,6 +2295,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_closePath(QV4::SimpleCallC */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_fill(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT(r); r->context->fill(); @@ -2299,6 +2309,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_fill(QV4::SimpleCallContex */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_lineTo(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT(r) @@ -2323,6 +2334,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_lineTo(QV4::SimpleCallCont */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_moveTo(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT(r) @@ -2346,6 +2358,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_moveTo(QV4::SimpleCallCont */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_quadraticCurveTo(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT(r) @@ -2371,6 +2384,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_quadraticCurveTo(QV4::Simp */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_rect(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT(r) @@ -2387,6 +2401,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_rect(QV4::SimpleCallContex */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_roundedRect(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT(r) @@ -2410,6 +2425,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_roundedRect(QV4::SimpleCal */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_ellipse(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT(r) @@ -2428,6 +2444,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_ellipse(QV4::SimpleCallCon */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_text(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT(r) @@ -2453,6 +2470,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_text(QV4::SimpleCallContex */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_stroke(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT(r) @@ -2480,21 +2498,21 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_isPointInPath(QV4::SimpleC QV4::ReturnedValue QQuickJSContext2DPrototype::method_drawFocusRing(QV4::SimpleCallContext *ctx) { - Q_UNUSED(ctx); + QV4::Scope scope(ctx); V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Context2D::drawFocusRing is not supported"); } QV4::ReturnedValue QQuickJSContext2DPrototype::method_setCaretSelectionRect(QV4::SimpleCallContext *ctx) { - Q_UNUSED(ctx); + QV4::Scope scope(ctx); V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Context2D::setCaretSelectionRect is not supported"); } QV4::ReturnedValue QQuickJSContext2DPrototype::method_caretBlinkRate(QV4::SimpleCallContext *ctx) { - Q_UNUSED(ctx); + QV4::Scope scope(ctx); V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Context2D::caretBlinkRate is not supported"); } @@ -2524,6 +2542,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_caretBlinkRate(QV4::Simple */ QV4::ReturnedValue QQuickJSContext2D::method_get_font(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT(r) @@ -2532,6 +2551,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_get_font(QV4::SimpleCallContext *ct QV4::ReturnedValue QQuickJSContext2D::method_set_font(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT_SETTER(r) @@ -2559,6 +2579,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_font(QV4::SimpleCallContext *ct */ QV4::ReturnedValue QQuickJSContext2D::method_get_textAlign(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT(r) @@ -2580,6 +2601,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_get_textAlign(QV4::SimpleCallContex QV4::ReturnedValue QQuickJSContext2D::method_set_textAlign(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT_SETTER(r) @@ -2622,6 +2644,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_textAlign(QV4::SimpleCallContex */ QV4::ReturnedValue QQuickJSContext2D::method_get_textBaseline(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT(r) @@ -2643,6 +2666,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_get_textBaseline(QV4::SimpleCallCon QV4::ReturnedValue QQuickJSContext2D::method_set_textBaseline(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT_SETTER(r) QString textBaseline = ctx->argument(0).toQStringNoThrow(); @@ -2677,6 +2701,7 @@ QV4::ReturnedValue QQuickJSContext2D::method_set_textBaseline(QV4::SimpleCallCon */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_fillText(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT(r) @@ -2700,6 +2725,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_fillText(QV4::SimpleCallCo */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_strokeText(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT(r) @@ -2734,6 +2760,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_strokeText(QV4::SimpleCall */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_measureText(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT(r) @@ -2808,6 +2835,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_measureText(QV4::SimpleCal */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_drawImage(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT(r) @@ -2942,6 +2970,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_drawImage(QV4::SimpleCallC */ QV4::ReturnedValue QQuickJSContext2DImageData::method_get_width(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2DImageData *imageData = ctx->thisObject.as<QQuickJSContext2DImageData>(); if (!imageData) ctx->throwTypeError(); @@ -2957,6 +2986,7 @@ QV4::ReturnedValue QQuickJSContext2DImageData::method_get_width(QV4::SimpleCallC */ QV4::ReturnedValue QQuickJSContext2DImageData::method_get_height(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2DImageData *imageData = ctx->thisObject.as<QQuickJSContext2DImageData>(); if (!imageData) ctx->throwTypeError(); @@ -2972,6 +3002,7 @@ QV4::ReturnedValue QQuickJSContext2DImageData::method_get_height(QV4::SimpleCall */ QV4::ReturnedValue QQuickJSContext2DImageData::method_get_data(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2DImageData *imageData = ctx->thisObject.as<QQuickJSContext2DImageData>(); if (!imageData) ctx->throwTypeError(); @@ -2998,6 +3029,7 @@ QV4::ReturnedValue QQuickJSContext2DImageData::method_get_data(QV4::SimpleCallCo */ QV4::ReturnedValue QQuickJSContext2DPixelData::proto_get_length(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2DPixelData *r = ctx->thisObject.as<QQuickJSContext2DPixelData>(); if (!r || r->image.isNull()) return QV4::Encode::undefined(); @@ -3088,6 +3120,7 @@ void QQuickJSContext2DPixelData::putIndexed(QV4::Managed *m, uint index, const Q */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createImageData(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT(r) @@ -3126,6 +3159,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_createImageData(QV4::Simpl */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_getImageData(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT(r) @@ -3155,6 +3189,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_getImageData(QV4::SimpleCa */ QV4::ReturnedValue QQuickJSContext2DPrototype::method_putImageData(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickJSContext2D *r = ctx->thisObject.as<QQuickJSContext2D>(); CHECK_CONTEXT(r) if (ctx->argumentCount != 3 && ctx->argumentCount != 7) @@ -3254,6 +3289,7 @@ QV4::ReturnedValue QQuickJSContext2DPrototype::method_putImageData(QV4::SimpleCa */ QV4::ReturnedValue QQuickContext2DStyle::gradient_proto_addColorStop(QV4::SimpleCallContext *ctx) { + QV4::Scope scope(ctx); QQuickContext2DStyle *style = ctx->thisObject.as<QQuickContext2DStyle>(); if (!style) V4THROW_ERROR("Not a CanvasGradient object"); |