Fix this object in constructor callbacks through the v8 compatibility layer
authorSimon Hausmann <simon.hausmann@digia.com>
Wed, 12 Jun 2013 08:18:21 +0000 (10:18 +0200)
committerLars Knoll <lars.knoll@digia.com>
Wed, 12 Jun 2013 08:19:10 +0000 (10:19 +0200)
Make sure that the thisObject is set, so that the XHR constructor can
set an external resource correctly.

Change-Id: Id217247cafcee42806dd75b5f461df87c296b81b
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/qml/qml/v4/qv4v8.cpp

index a507560..0542e1c 100644 (file)
@@ -1163,13 +1163,14 @@ protected:
     static QV4::Value construct(QV4::Managed *m, ExecutionContext *context, QV4::Value *args, int argc)
     {
         V4V8Function *that = static_cast<V4V8Function*>(m);
-        Arguments arguments(args, argc, QV4::Value::undefinedValue(), true, that->m_functionTemplate->m_data.value());
 
         QV4::Object *obj = that->m_functionTemplate->InstanceTemplate()->NewInstance()->v4Value().asObject();
         QV4::Value proto = that->Managed::get(context, context->engine->id_prototype);
         if (proto.isObject())
             obj->prototype = proto.objectValue();
 
+        Arguments arguments(args, argc, QV4::Value::fromObject(obj), true, that->m_functionTemplate->m_data.value());
+
         QV4::Value result = QV4::Value::undefinedValue();
         if (that->m_functionTemplate->m_callback)
             result = that->m_functionTemplate->m_callback(arguments);