Guard QML-specific handling of value type property access
authorKent Hansen <kent.hansen@nokia.com>
Thu, 11 Aug 2011 07:28:22 +0000 (09:28 +0200)
committerQt by Nokia <qt-info@nokia.com>
Thu, 11 Aug 2011 08:22:09 +0000 (10:22 +0200)
When using QJSEngine, there is no QDeclarativeEngine
associated with the QV8Engine, so check if it's there first.

This was causing the QJS qobject bindings autotest to crash.

Change-Id: If2c1d414d615bfbe93580d06555f5c17b0e41eef
Reviewed-on: http://codereview.qt.nokia.com/2845
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
src/declarative/qml/v8/qv8qobjectwrapper.cpp

index 54366af..c7ed011 100644 (file)
@@ -336,7 +336,8 @@ static v8::Handle<v8::Value> LoadProperty(QV8Engine *engine, QObject *object,
         void *args[] = { &handle, 0 };
         QMetaObject::metacall(object, QMetaObject::ReadProperty, property.coreIndex, args); 
         return handle.toHandle();
-    } else if (QDeclarativeValueTypeFactory::isValueType((uint)property.propType)) {
+    } else if (QDeclarativeValueTypeFactory::isValueType((uint)property.propType)
+               && engine->engine()) {
         QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine->engine());
         QDeclarativeValueType *valueType = ep->valueTypes[property.propType];
         if (valueType)
@@ -381,7 +382,8 @@ static v8::Handle<v8::Value> LoadPropertyDirect(QV8Engine *engine, QObject *obje
         void *args[] = { &handle, 0 };
         object->qt_metacall(QMetaObject::ReadProperty, property.coreIndex, args); 
         return handle.toHandle();
-    } else if (QDeclarativeValueTypeFactory::isValueType((uint)property.propType)) {
+    } else if (QDeclarativeValueTypeFactory::isValueType((uint)property.propType)
+               && engine->engine()) {
         QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine->engine());
         QDeclarativeValueType *valueType = ep->valueTypes[property.propType];
         if (valueType)