summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-10-05 17:16:37 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-10-06 08:16:40 (GMT)
commit37bd7a5711e57ea8c45ae75102ddee3ab905a0e5 (patch)
tree62ad5ea444763c07caca7206bf488d3f65f8547e /src
parent39dc3026d1da03d5fcf8e5c516fadd7e4ea8a861 (diff)
downloadQt-37bd7a5711e57ea8c45ae75102ddee3ab905a0e5.zip
Qt-37bd7a5711e57ea8c45ae75102ddee3ab905a0e5.tar.gz
Qt-37bd7a5711e57ea8c45ae75102ddee3ab905a0e5.tar.bz2
QScript: do not crash on PowerPC
There is no 'this' register in the global context. The computation of the this register for the global context gives the 'codeBlock' register in the frame header. On Intel processor, a JSValue() is 0x0 when converted to a pointer, but this is not the case on PowerPC (it is 0xfffffff9) so it just crash later when acessing the code block. Solution: special condition for the global context when getting the 'this' object Reviewed-by: Kent Hansen
Diffstat (limited to 'src')
-rw-r--r--src/script/api/qscriptengine.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 09042e1..3402190 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -805,7 +805,6 @@ QScriptEnginePrivate::QScriptEnginePrivate()
JSC::JSGlobalObject *globalObject = new (globalData)QScript::GlobalObject();
JSC::ExecState* exec = globalObject->globalExec();
- *thisRegisterForFrame(exec) = JSC::JSValue();
scriptObjectStructure = QScriptObject::createStructure(globalObject->objectPrototype());
@@ -1079,12 +1078,13 @@ JSC::JSValue QScriptEnginePrivate::toUsableValue(JSC::JSValue value)
/*!
\internal
Return the 'this' value for a given context
- The result may be null for the global context
*/
JSC::JSValue QScriptEnginePrivate::thisForContext(JSC::ExecState *frame)
{
if (frame->codeBlock() != 0) {
return frame->thisValue();
+ } else if(frame == frame->lexicalGlobalObject()->globalExec()) {
+ return frame->globalThisValue();
} else {
JSC::Register *thisRegister = thisRegisterForFrame(frame);
return thisRegister->jsValue();