From e06676db83483d83260f7e04bd1ae2024d8b5030 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 13 Jun 2013 14:36:32 +0200 Subject: [PATCH] Don't allow for a QJSValue to be taken from one engine to another through QVariant Change-Id: I21127d22f595b0ff88f6073bddf617423ad17867 Reviewed-by: Lars Knoll --- src/qml/qml/v8/qjsvalue_p.h | 4 ++++ tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/qml/qml/v8/qjsvalue_p.h b/src/qml/qml/v8/qjsvalue_p.h index bb92010..3b05af2 100644 --- a/src/qml/qml/v8/qjsvalue_p.h +++ b/src/qml/qml/v8/qjsvalue_p.h @@ -92,6 +92,10 @@ public: QV4::Value getValue(QV4::ExecutionEngine *e) { if (!this->e) this->e = e; + else if (this->e != e) { + qWarning("JSValue can't be reassigned to another engine."); + return QV4::Value::emptyValue(); + } if (value.asString() == &string) value = QV4::Value::fromString(e->newString(string.toQString())); return value; diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index 325deba..9fe4fb7 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -3529,7 +3529,7 @@ void tst_qqmlecmascript::signalWithJSValueInVariant_twoEngines() object->setProperty("compare", compare); object->setProperty("pass", false); - QTest::ignoreMessage(QtWarningMsg, "JSValue can't be rassigned to an another engine."); + QTest::ignoreMessage(QtWarningMsg, "JSValue can't be reassigned to another engine."); emit object->signalWithVariant(QVariant::fromValue(value)); QVERIFY(!object->property("pass").toBool()); } -- 2.7.4