diff options
-rw-r--r-- | src/declarative/qml/qmlcontextscriptclass.cpp | 9 | ||||
-rw-r--r-- | src/declarative/qml/qmllistscriptclass.cpp | 12 | ||||
-rw-r--r-- | src/declarative/qml/qmlobjectscriptclass.cpp | 31 | ||||
-rw-r--r-- | src/declarative/qml/qmltypenamescriptclass.cpp | 5 | ||||
-rw-r--r-- | src/declarative/qml/qmlvaluetypescriptclass.cpp | 3 |
5 files changed, 31 insertions, 29 deletions
diff --git a/src/declarative/qml/qmlcontextscriptclass.cpp b/src/declarative/qml/qmlcontextscriptclass.cpp index 8ab3f8d..71b77d5 100644 --- a/src/declarative/qml/qmlcontextscriptclass.cpp +++ b/src/declarative/qml/qmlcontextscriptclass.cpp @@ -206,6 +206,7 @@ QmlContextScriptClass::property(Object *object, const Identifier &name) QmlEnginePrivate *ep = QmlEnginePrivate::get(engine); QmlContextPrivate *cp = QmlContextPrivate::get(bindContext); + QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); if (lastScopeObject) { @@ -214,9 +215,9 @@ QmlContextScriptClass::property(Object *object, const Identifier &name) } else if (lastData) { if (lastData->type) - return ep->typeNameClass->newObject(cp->defaultObjects.at(0), lastData->type); + return Value(scriptEngine, ep->typeNameClass->newObject(cp->defaultObjects.at(0), lastData->type)); else - return ep->typeNameClass->newObject(cp->defaultObjects.at(0), lastData->typeNamespace); + return Value(scriptEngine, ep->typeNameClass->newObject(cp->defaultObjects.at(0), lastData->typeNamespace)); } else if (lastPropertyIndex != -1) { @@ -231,7 +232,7 @@ QmlContextScriptClass::property(Object *object, const Identifier &name) ep->capturedProperties << QmlEnginePrivate::CapturedProperty(bindContext, -1, lastPropertyIndex + cp->notifyIndex); - return rv; + return Value(scriptEngine, rv); } else if(lastDefaultObject != -1) { // Default object property @@ -239,7 +240,7 @@ QmlContextScriptClass::property(Object *object, const Identifier &name) } else { - return lastFunction; + return Value(scriptEngine, lastFunction); } } diff --git a/src/declarative/qml/qmllistscriptclass.cpp b/src/declarative/qml/qmllistscriptclass.cpp index b275625..4b8b056 100644 --- a/src/declarative/qml/qmllistscriptclass.cpp +++ b/src/declarative/qml/qmllistscriptclass.cpp @@ -107,7 +107,7 @@ QmlListScriptClass::Value QmlListScriptClass::property(Object *obj, const Identi ListData *data = (ListData *)obj; if (!data->object) - return scriptEngine->undefinedValue(); + return Value(); void *list = 0; void *args[] = { &list, 0 }; @@ -115,7 +115,7 @@ QmlListScriptClass::Value QmlListScriptClass::property(Object *obj, const Identi data->propertyIdx, args); if (!list) - return scriptEngine->undefinedValue(); + return Value(); if (data->type == QListPtr) { const QList<QObject *> &qlist = *((QList<QObject *>*)list); @@ -125,9 +125,9 @@ QmlListScriptClass::Value QmlListScriptClass::property(Object *obj, const Identi if (name == m_lengthId.identifier) return Value(scriptEngine, count); else if (lastIndex < count) - return enginePriv->objectClass->newQObject(qlist.at(lastIndex)); + return Value(scriptEngine, enginePriv->objectClass->newQObject(qlist.at(lastIndex))); else - return scriptEngine->undefinedValue(); + return Value(); } else { Q_ASSERT(data->type == QmlListPtr); @@ -138,9 +138,9 @@ QmlListScriptClass::Value QmlListScriptClass::property(Object *obj, const Identi if (name == m_lengthId.identifier) return Value(scriptEngine, count); else if (lastIndex < count) - return enginePriv->objectClass->newQObject(qmllist.at(lastIndex)); + return Value(scriptEngine, enginePriv->objectClass->newQObject(qmllist.at(lastIndex))); else - return scriptEngine->undefinedValue(); + return Value(); } } diff --git a/src/declarative/qml/qmlobjectscriptclass.cpp b/src/declarative/qml/qmlobjectscriptclass.cpp index fbd123a..5de42b9 100644 --- a/src/declarative/qml/qmlobjectscriptclass.cpp +++ b/src/declarative/qml/qmlobjectscriptclass.cpp @@ -198,33 +198,34 @@ QmlObjectScriptClass::property(Object *object, const Identifier &name) QmlObjectScriptClass::Value QmlObjectScriptClass::property(QObject *obj, const Identifier &name) { + QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); + if (name == m_destroyId.identifier) - return m_destroy; + return Value(scriptEngine, m_destroy); else if (name == m_toStringId.identifier) - return m_toString; + return Value(scriptEngine, m_toString); if (lastData && !lastData->isValid()) - return QmlEnginePrivate::getScriptEngine(engine)->undefinedValue(); + return Value(); Q_ASSERT(obj); - QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); QmlEnginePrivate *enginePriv = QmlEnginePrivate::get(engine); if (lastTNData) { if (lastTNData->type) - return enginePriv->typeNameClass->newObject(obj, lastTNData->type); + return Value(scriptEngine, enginePriv->typeNameClass->newObject(obj, lastTNData->type)); else - return enginePriv->typeNameClass->newObject(obj, lastTNData->typeNamespace); + return Value(scriptEngine, enginePriv->typeNameClass->newObject(obj, lastTNData->typeNamespace)); } else if (lastData->flags & QmlPropertyCache::Data::IsFunction) { if (lastData->flags & QmlPropertyCache::Data::IsVMEFunction) { - return ((QmlVMEMetaObject *)(obj->metaObject()))->vmeMethod(lastData->coreIndex); + return Value(scriptEngine, ((QmlVMEMetaObject *)(obj->metaObject()))->vmeMethod(lastData->coreIndex)); } else { // ### Optimize QScriptValue sobj = scriptEngine->newQObject(obj); - return sobj.property(toString(name)); + return Value(scriptEngine, sobj.property(toString(name))); } } else { if (enginePriv->captureProperties && !(lastData->flags & QmlPropertyCache::Data::IsConstant)) { @@ -235,25 +236,23 @@ QmlObjectScriptClass::property(QObject *obj, const Identifier &name) if ((uint)lastData->propType < QVariant::UserType) { QmlValueType *valueType = enginePriv->valueTypes[lastData->propType]; if (valueType) - return enginePriv->valueTypeClass->newObject(obj, lastData->coreIndex, valueType); + return Value(scriptEngine, enginePriv->valueTypeClass->newObject(obj, lastData->coreIndex, valueType)); } if (lastData->flags & QmlPropertyCache::Data::IsQList) { - return enginePriv->listClass->newList(obj, lastData->coreIndex, - QmlListScriptClass::QListPtr); + return Value(scriptEngine, enginePriv->listClass->newList(obj, lastData->coreIndex, QmlListScriptClass::QListPtr)); } else if (lastData->flags & QmlPropertyCache::Data::IsQmlList) { - return enginePriv->listClass->newList(obj, lastData->coreIndex, - QmlListScriptClass::QmlListPtr); + return Value(scriptEngine, enginePriv->listClass->newList(obj, lastData->coreIndex, QmlListScriptClass::QmlListPtr)); } else if (lastData->flags & QmlPropertyCache::Data::IsQObjectDerived) { QObject *rv = 0; void *args[] = { &rv, 0 }; QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args); - return newQObject(rv, lastData->propType); + return Value(scriptEngine, newQObject(rv, lastData->propType)); } else if (lastData->flags & QmlPropertyCache::Data::IsQScriptValue) { QScriptValue rv = scriptEngine->nullValue(); void *args[] = { &rv, 0 }; QMetaObject::metacall(obj, QMetaObject::ReadProperty, lastData->coreIndex, args); - return rv; + return Value(scriptEngine, rv); } else if (lastData->propType == QMetaType::QReal) { qreal rv = 0; void *args[] = { &rv, 0 }; @@ -291,7 +290,7 @@ QmlObjectScriptClass::property(QObject *obj, const Identifier &name) return Value(scriptEngine, rv); } else { QVariant var = obj->metaObject()->property(lastData->coreIndex).read(obj); - return enginePriv->scriptValueFromVariant(var); + return Value(scriptEngine, enginePriv->scriptValueFromVariant(var)); } } diff --git a/src/declarative/qml/qmltypenamescriptclass.cpp b/src/declarative/qml/qmltypenamescriptclass.cpp index 3e4b08c..3c57223 100644 --- a/src/declarative/qml/qmltypenamescriptclass.cpp +++ b/src/declarative/qml/qmltypenamescriptclass.cpp @@ -142,12 +142,13 @@ QmlTypeNameScriptClass::queryProperty(Object *obj, const Identifier &name, QmlTypeNameScriptClass::Value QmlTypeNameScriptClass::property(Object *obj, const Identifier &name) { QmlEnginePrivate *ep = QmlEnginePrivate::get(engine); + QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); if (type) { - return newObject(((TypeNameData *)obj)->object, type, ((TypeNameData *)obj)->mode); + return Value(scriptEngine, newObject(((TypeNameData *)obj)->object, type, ((TypeNameData *)obj)->mode)); } else if (object) { return ep->objectClass->property(object, name); } else { - return Value(&ep->scriptEngine, enumValue); + return Value(scriptEngine, enumValue); } } diff --git a/src/declarative/qml/qmlvaluetypescriptclass.cpp b/src/declarative/qml/qmlvaluetypescriptclass.cpp index 65a63f4..90de6e7 100644 --- a/src/declarative/qml/qmlvaluetypescriptclass.cpp +++ b/src/declarative/qml/qmlvaluetypescriptclass.cpp @@ -106,7 +106,8 @@ QmlValueTypeScriptClass::Value QmlValueTypeScriptClass::property(Object *obj, co ref->type->read(ref->object, ref->property); QVariant rv = p.read(ref->type); - return static_cast<QmlEnginePrivate *>(QObjectPrivate::get(engine))->scriptValueFromVariant(rv); + QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); + return Value(scriptEngine, static_cast<QmlEnginePrivate *>(QObjectPrivate::get(engine))->scriptValueFromVariant(rv)); } void QmlValueTypeScriptClass::setProperty(Object *obj, const Identifier &, |