Fix incorrect automatic context memory management when using pushGlobalContext()
authorSimon Hausmann <simon.hausmann@digia.com>
Fri, 28 Jun 2013 21:59:23 +0000 (23:59 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Sun, 30 Jun 2013 16:14:22 +0000 (18:14 +0200)
commitda3acc34ab9c1ab4ef8dc1277fba9b783adfe025
tree5a7dfeaf5f8f46609a7f3b013046f5ae8300fae4
parenta1f4211ddea00c051647bda9a7fcd841f946dea8
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>
src/qml/qml/v4/qv4engine.cpp