From f7455c339077078ed5986a09ee862410e0525a77 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 28 Jul 2009 15:12:33 +0200 Subject: Set the this object on the global context sets the global object Reviewed-by: Kent Hansen --- src/script/api/qscriptcontext.cpp | 2 +- tests/auto/qscriptcontext/tst_qscriptcontext.cpp | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/script/api/qscriptcontext.cpp b/src/script/api/qscriptcontext.cpp index c286a70..9ac0dc8 100644 --- a/src/script/api/qscriptcontext.cpp +++ b/src/script/api/qscriptcontext.cpp @@ -476,7 +476,7 @@ void QScriptContext::setThisObject(const QScriptValue &thisObject) return; } if (d->frame == d->engine->globalExec()) { - qWarning("QScriptContext::setThisObject(): setting this-object of global context is not supported"); + engine()->setGlobalObject(thisObject); return; } JSC::JSValue jscThisObject = d->engine->scriptValueToJSCValue(thisObject); diff --git a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp index 524fff2..8b3d1d7 100644 --- a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp +++ b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp @@ -286,10 +286,8 @@ void tst_QScriptContext::thisObject() { QScriptValue obj = eng.newObject(); eng.currentContext()->setThisObject(obj); - QEXPECT_FAIL("", "Setting this-object of global context doesn't work", Continue); QVERIFY(eng.currentContext()->thisObject().equals(obj)); eng.currentContext()->setThisObject(QScriptValue()); - QEXPECT_FAIL("", "Setting this-object of global context doesn't work", Continue); QVERIFY(eng.currentContext()->thisObject().equals(obj)); QScriptEngine eng2; -- cgit v0.12