Fix crash in QQmlXmlHttpRequest
authorChris Adams <christopher.adams@nokia.com>
Mon, 23 Apr 2012 06:37:05 +0000 (16:37 +1000)
committerQt by Nokia <qt-info@nokia.com>
Mon, 2 Jul 2012 07:43:36 +0000 (09:43 +0200)
commitfdeee38b781376012c4f086276c3c376726c8839
treee35e5f02ec00a1750854bb81c7e4d5d85a4dd8ae
parent4c02780738241d784849f423944a8a4852022967
Fix crash in QQmlXmlHttpRequest

If an onreadystatechange handler of a QQmlXmlHttpRequest uses code
which requires the engine->callingContext() to be valid, a crash
could previously occur (since the callingContext() would be null
if the handler was called due to a network request finishing.

This commit saves the calling context on send, so that on dispatch
we can create an activation scope from that context and use it.
Note that even in this case, if the original context had previously
been deleted (e.g., by a loader deleting the item context on source
change) the saved context could be invalid by the time the dispatch
function was invoked.  In that case, we simply do nothing as the
function call cannot succeed (invalid context).

Change-Id: Iba357829a69433c11cc279e6cc9fdc0bedaa31fb
Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
src/qml/qml/qqmlxmlhttprequest.cpp
tests/auto/qml/qqmlxmlhttprequest/data/TestComponent.qml [new file with mode: 0644]
tests/auto/qml/qqmlxmlhttprequest/data/TestComponent2.qml [new file with mode: 0644]
tests/auto/qml/qqmlxmlhttprequest/data/TestComponent3.qml [new file with mode: 0644]
tests/auto/qml/qqmlxmlhttprequest/data/stateChangeCallingContext.qml [new file with mode: 0644]
tests/auto/qml/qqmlxmlhttprequest/data/testlist [new file with mode: 0644]
tests/auto/qml/qqmlxmlhttprequest/tst_qqmlxmlhttprequest.cpp