summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-08-19 14:51:43 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-08-19 14:52:55 (GMT)
commit3f9a1230e32cb43d61c8d42c9bcb2beb322f6583 (patch)
tree907b9134b89f4934a3980747f598827ac194c517
parent7ae701ff4759bdfd12953c6f4d785c2d9241690f (diff)
downloadQt-3f9a1230e32cb43d61c8d42c9bcb2beb322f6583.zip
Qt-3f9a1230e32cb43d61c8d42c9bcb2beb322f6583.tar.gz
Qt-3f9a1230e32cb43d61c8d42c9bcb2beb322f6583.tar.bz2
invalidate wrapped JSC::JSValue when script engine is deleted
Otherwise we will crash if someone tries to do something with the value.
-rw-r--r--src/script/api/qscriptvalue_p.h7
-rw-r--r--tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp4
2 files changed, 6 insertions, 5 deletions
diff --git a/src/script/api/qscriptvalue_p.h b/src/script/api/qscriptvalue_p.h
index 7c1d538..71bff07 100644
--- a/src/script/api/qscriptvalue_p.h
+++ b/src/script/api/qscriptvalue_p.h
@@ -144,8 +144,11 @@ public:
{
// if type is not developed in js engine there is no
// need to invalidate the object
- if (isJSC()) valid=false;
- engine=0;
+ if (isJSC()) {
+ valid = false;
+ jscValue = JSC::JSValue();
+ }
+ engine = 0;
}
qint64 objectId()
diff --git a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
index 343d91d..8de6c4e 100644
--- a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
+++ b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp
@@ -1889,9 +1889,7 @@ void tst_QScriptExtQObject::cppConnectAndDisconnect()
QVERIFY(qScriptConnect(&edit, SIGNAL(textChanged(const QString &)), QScriptValue(), fun2));
delete eng2;
edit.setText("ciao");
- QEXPECT_FAIL("", "Crashes", Continue);
- QVERIFY(false);
- // QVERIFY(!qScriptDisconnect(&edit, SIGNAL(textChanged(const QString &)), QScriptValue(), fun2));
+ QVERIFY(!qScriptDisconnect(&edit, SIGNAL(textChanged(const QString &)), QScriptValue(), fun2));
}
// mixing script-side and C++-side connect