summaryrefslogtreecommitdiffstats
path: root/src/script/bridge
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-07-29 10:58:20 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-07-29 10:59:12 (GMT)
commitad255eac6aaba9ac1689145bbf47376c354996aa (patch)
tree6094a1775227e290b3d0d62647e7162188b9823b /src/script/bridge
parent1ae869d6dfaf3f07d5cdb1fd951a711edd96eff7 (diff)
downloadQt-ad255eac6aaba9ac1689145bbf47376c354996aa.zip
Qt-ad255eac6aaba9ac1689145bbf47376c354996aa.tar.gz
Qt-ad255eac6aaba9ac1689145bbf47376c354996aa.tar.bz2
set calledAsConstructor to true when function is called as constructor
Diffstat (limited to 'src/script/bridge')
-rw-r--r--src/script/bridge/qscriptclassobject.cpp3
-rw-r--r--src/script/bridge/qscriptfunction.cpp2
2 files changed, 5 insertions, 0 deletions
diff --git a/src/script/bridge/qscriptclassobject.cpp b/src/script/bridge/qscriptclassobject.cpp
index e173ebc..512c00e 100644
--- a/src/script/bridge/qscriptclassobject.cpp
+++ b/src/script/bridge/qscriptclassobject.cpp
@@ -45,6 +45,8 @@
#include "../api/qscriptengine.h"
#include "../api/qscriptengine_p.h"
+#include "../api/qscriptcontext.h"
+#include "../api/qscriptcontext_p.h"
#include "../api/qscriptclass.h"
#include "../api/qscriptclasspropertyiterator.h"
@@ -240,6 +242,7 @@ JSC::JSObject* ClassObjectDelegate::construct(JSC::ExecState *exec, JSC::JSObjec
QScriptEnginePrivate *eng_p = scriptEngineFromExec(exec);
JSC::ExecState *previousFrame = eng_p->currentFrame;
QScriptContext *ctx = eng_p->contextForFrame(exec);
+ QScriptContextPrivate::get(ctx)->calledAsConstructor = true;
eng_p->currentFrame = exec;
QScriptValue defaultObject = ctx->thisObject();
QScriptValue result = qvariant_cast<QScriptValue>(scriptClass->extension(QScriptClass::Callable, qVariantFromValue(ctx)));
diff --git a/src/script/bridge/qscriptfunction.cpp b/src/script/bridge/qscriptfunction.cpp
index ef97f6f..777bd3b 100644
--- a/src/script/bridge/qscriptfunction.cpp
+++ b/src/script/bridge/qscriptfunction.cpp
@@ -143,6 +143,7 @@ JSC::JSObject* FunctionWrapper::proxyConstruct(JSC::ExecState *exec, JSC::JSObje
QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(self->data->engine);
JSC::ExecState *previousFrame = eng_p->currentFrame;
QScriptContext *ctx = eng_p->contextForFrame(exec);
+ QScriptContextPrivate::get(ctx)->calledAsConstructor = true;
eng_p->currentFrame = exec;
//We might have nested eval inside our function so we should create another scope
@@ -213,6 +214,7 @@ JSC::JSObject* FunctionWithArgWrapper::proxyConstruct(JSC::ExecState *exec, JSC:
QScriptEnginePrivate *eng_p = QScriptEnginePrivate::get(self->data->engine);
JSC::ExecState *previousFrame = eng_p->currentFrame;
QScriptContext *ctx = eng_p->contextForFrame(exec);
+ QScriptContextPrivate::get(ctx)->calledAsConstructor = true;
eng_p->currentFrame = exec;
//We might have nested eval inside our function so we should create another scope