aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/v4
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-06-28 23:59:23 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-06-30 18:14:22 +0200
commitda3acc34ab9c1ab4ef8dc1277fba9b783adfe025 (patch)
tree5a7dfeaf5f8f46609a7f3b013046f5ae8300fae4 /src/qml/qml/v4
parenta1f4211ddea00c051647bda9a7fcd841f946dea8 (diff)
Fix incorrect automatic context memory management when using pushGlobalContext()
The automatic memory management of contexts relies on allocContext() returning a new context that has its next member set to the previous head of the global MM::m_contextList. Engine::pushGlobalContext() broke this chain by copying all fields from *rootContext and thus "resetting" the entire context chain more or less. That would mean a lot of contexts would suddenly just hang around (never get collected and more importantly their marked bit not reset) and objects that would only be kept alive by those contexts (such as QML context wrappers of signal handler closures) would get erroneously collected. This patch preserves the next field correctly in pushGlobalContext() (which we for example use before instantiating qml singletons) Change-Id: Id28d7112e1cba905d12b8fc7e3d94dab4eea2375 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml/v4')
-rw-r--r--src/qml/qml/v4/qv4engine.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/qml/qml/v4/qv4engine.cpp b/src/qml/qml/v4/qv4engine.cpp
index b2893f02d6..343e24f1bf 100644
--- a/src/qml/qml/v4/qv4engine.cpp
+++ b/src/qml/qml/v4/qv4engine.cpp
@@ -368,7 +368,9 @@ CallContext *ExecutionEngine::newCallContext(void *stackSpace, FunctionObject *f
ExecutionContext *ExecutionEngine::pushGlobalContext()
{
GlobalContext *g = static_cast<GlobalContext *>(memoryManager->allocContext(sizeof(GlobalContext)));
+ ExecutionContext *oldNext = g->next;
*g = *rootContext;
+ g->next = oldNext;
g->parent = current;
current = g;