Don't allow for a QJSValue to be taken from one engine to another through QVariant
authorSimon Hausmann <simon.hausmann@digia.com>
Thu, 13 Jun 2013 12:36:32 +0000 (14:36 +0200)
committerLars Knoll <lars.knoll@digia.com>
Thu, 13 Jun 2013 15:47:44 +0000 (17:47 +0200)
Change-Id: I21127d22f595b0ff88f6073bddf617423ad17867
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/qml/qml/v8/qjsvalue_p.h
tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp

index bb92010..3b05af2 100644 (file)
@@ -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;
index 325deba..9fe4fb7 100644 (file)
@@ -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());
 }