Fix incorrect automatic context memory management when using pushGlobalContext()
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 <a812617a4072dcbeb80684eca0f369f0083af109@digia.com>

matthewvogt/qtdeclarative,qmlc/qtdeclarative,mgrunditz/qtdeclarative-2d,mgrunditz/qtdeclarative-2d,mgrunditz/qtdeclarative-2d,mgrunditz/qtdeclarative-2d,matthewvogt/qtdeclarative,matthewvogt/qtdeclarative,matthewvogt/qtdeclarative,qmlc/qtdeclarative,qmlc/qtdeclarative,mgrunditz/qtdeclarative-2d,matthewvogt/qtdeclarative,matthewvogt/qtdeclarative,mgrunditz/qtdeclarative-2d,qmlc/qtdeclarative,matthewvogt/qtdeclarative,matthewvogt/qtdeclarative,qmlc/qtdeclarative,qmlc/qtdeclarative,qmlc/qtdeclarative,qmlc/qtdeclarative,mgrunditz/qtdeclarative-2d