summaryrefslogtreecommitdiffstats
path: root/src/script/api
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-09-22 14:56:37 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-09-22 14:59:39 (GMT)
commit77b1f0ab8c8055835a3fc92d784d536efdc6acbf (patch)
treee844d05c320702802f5fd6b041d6085054c9d560 /src/script/api
parent5c3c0d477104f6f4eafaceeacac8278c4b97f8cc (diff)
downloadQt-77b1f0ab8c8055835a3fc92d784d536efdc6acbf.zip
Qt-77b1f0ab8c8055835a3fc92d784d536efdc6acbf.tar.gz
Qt-77b1f0ab8c8055835a3fc92d784d536efdc6acbf.tar.bz2
make sure the engine's currentFrame is in sync when calling out to public API
The currentFrame pointer is used e.g. by QScriptValue::toString(). It needs to be in sync, otherwise we will crash. Reviewed-by: Olivier Goffart
Diffstat (limited to 'src/script/api')
-rw-r--r--src/script/api/qscriptengine.cpp2
-rw-r--r--src/script/api/qscriptengine_p.h23
2 files changed, 25 insertions, 0 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 7a910d2..71194d3 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -508,6 +508,7 @@ JSC::JSValue JSC_HOST_CALL functionDisconnect(JSC::ExecState *exec, JSC::JSObjec
slot = arg1;
else {
// ### don't go via QScriptValue
+ QScript::SaveFrameHelper saveFrame(engine, exec);
QScriptValue tmp = engine->scriptValueFromJSCValue(arg0);
QString propertyName(arg1.toString(exec));
slot = engine->scriptValueToJSCValue(tmp.property(propertyName, QScriptValue::ResolvePrototype));
@@ -591,6 +592,7 @@ JSC::JSValue JSC_HOST_CALL functionConnect(JSC::ExecState *exec, JSC::JSObject *
slot = arg1;
else {
// ### don't go via QScriptValue
+ QScript::SaveFrameHelper saveFrame(engine, exec);
QScriptValue tmp = engine->scriptValueFromJSCValue(arg0);
QString propertyName = arg1.toString(exec);
slot = engine->scriptValueToJSCValue(tmp.property(propertyName, QScriptValue::ResolvePrototype));
diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h
index c7db276..ec41cc9 100644
--- a/src/script/api/qscriptengine_p.h
+++ b/src/script/api/qscriptengine_p.h
@@ -265,6 +265,29 @@ public:
#endif
};
+namespace QScript
+{
+
+class SaveFrameHelper
+{
+public:
+ SaveFrameHelper(QScriptEnginePrivate *eng,
+ JSC::ExecState *newFrame)
+ : engine(eng), oldFrame(eng->currentFrame)
+ {
+ eng->currentFrame = newFrame;
+ }
+ ~SaveFrameHelper()
+ {
+ engine->currentFrame = oldFrame;
+ }
+private:
+ QScriptEnginePrivate *engine;
+ JSC::ExecState *oldFrame;
+};
+
+} // namespace QScript
+
inline QScriptValuePrivate *QScriptEnginePrivate::allocateScriptValuePrivate(size_t size)
{
if (freeScriptValues) {