From 1d56e14605d74aefb955bdd81ee4083131252c9e Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Thu, 16 Jul 2009 11:46:36 +0200 Subject: only set default prototype if resulting object has built-in Object prototype as its prototype port of commit 4182e9c4b2cbfcd0604c57da210e97d68cbbbb52 in qt/master. --- src/script/api/qscriptengine.cpp | 5 ++++- tests/auto/qscriptqobject/tst_qscriptqobject.cpp | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index e020c93..702851a 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -2210,6 +2210,7 @@ QScriptValue QScriptEngine::create(int type, const void *ptr) QScriptValue QScriptEnginePrivate::create(int type, const void *ptr) { + Q_Q(QScriptEngine); Q_ASSERT(ptr != 0); QScriptValue result; QScriptTypeInfo *info = m_typeInfos.value(type); @@ -2323,8 +2324,10 @@ QScriptValue QScriptEnginePrivate::create(int type, const void *ptr) } } } - if (result.isObject() && info && info->prototype) + if (result.isObject() && info && info->prototype + && result.prototype().strictlyEquals(q->globalObject().property(QLatin1String("prototype")))) { result.setPrototype(scriptValueFromJSCValue(info->prototype)); + } return result; } diff --git a/tests/auto/qscriptqobject/tst_qscriptqobject.cpp b/tests/auto/qscriptqobject/tst_qscriptqobject.cpp index 8aea80a..8a041d5 100644 --- a/tests/auto/qscriptqobject/tst_qscriptqobject.cpp +++ b/tests/auto/qscriptqobject/tst_qscriptqobject.cpp @@ -1422,7 +1422,6 @@ void tst_QScriptExtQObject::callQtInvokable() QScriptValue ret = m_engine->evaluate("myObject.myInvokableReturningMyQObjectAsQObject()"); QCOMPARE(m_myObject->qtFunctionInvoked(), 57); QVERIFY(ret.isQObject()); - QEXPECT_FAIL("", "Doesn't work", Continue); QVERIFY(ret.prototype().strictlyEquals(myQObjectProto)); qScriptRegisterMetaType(m_engine, 0, 0, QScriptValue()); -- cgit v0.12