summaryrefslogtreecommitdiff
path: root/src/script/api
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2011-02-14 14:25:15 +1000
committerAaron Kennedy <aaron.kennedy@nokia.com>2011-02-14 14:36:57 +1000
commit3bc6f8d8dd630cd0298e27fc4b7430d2bf73a232 (patch)
tree55b7099a9044efb8182323fd67841b95616d82f7 /src/script/api
parent2855782a45b08aedbed960125514fdd9663ff1c8 (diff)
downloadqt4-tools-3bc6f8d8dd630cd0298e27fc4b7430d2bf73a232.tar.gz
Don't leak ScopeChainNode's
Create a sub-scope of the global scope chain, rather than a completely new scope chain. Leaks are difficult to autotest, but an autotest for QScriptDeclarativeClass::pushCleanContext() was added to ensure its behavior doesn't regress. To reproduce the leak (prior to this change) use: while (true) { QScriptDeclarativeClass::pushCleanContext(&engine); engine.popContext(); } Change-Id: I41ac61ea1664da569eb329c8276f2a0bb6d2f1f7 Task-number: QTBUG-17166 Reviewed-by: Martin Jones
Diffstat (limited to 'src/script/api')
-rw-r--r--src/script/api/qscriptengine.cpp4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp
index 54039c0759..e58c43b0ff 100644
--- a/src/script/api/qscriptengine.cpp
+++ b/src/script/api/qscriptengine.cpp
@@ -2761,9 +2761,7 @@ JSC::CallFrame *QScriptEnginePrivate::pushContext(JSC::CallFrame *exec, JSC::JSV
if (!clearScopeChain) {
newCallFrame->init(0, /*vPC=*/0, exec->scopeChain(), exec, flags | ShouldRestoreCallFrame, argc, callee);
} else {
- JSC::JSObject *jscObject = originalGlobalObject();
- JSC::ScopeChainNode *scn = new JSC::ScopeChainNode(0, jscObject, &exec->globalData(), exec->lexicalGlobalObject(), jscObject);
- newCallFrame->init(0, /*vPC=*/0, scn, exec, flags | ShouldRestoreCallFrame, argc, callee);
+ newCallFrame->init(0, /*vPC=*/0, globalExec()->scopeChain(), exec, flags | ShouldRestoreCallFrame, argc, callee);
}
} else {
setContextFlags(newCallFrame, flags);