Invalidate QScriptPrograms when engine is destroyed
authorKent Hansen <kent.hansen@nokia.com>
Fri, 28 Jan 2011 09:10:31 +0000 (10:10 +0100)
committerJason McDonald <jason.mcdonald@nokia.com>
Mon, 31 Jan 2011 13:14:38 +0000 (23:14 +1000)
commit307eceb786d3558b604c25353d67aed6ef9b0702
tree64dde4977c8fd3f5000676d03444c16314f2ccca
parent884dc710553c44277504245dc908f96731da84ed
Invalidate QScriptPrograms when engine is destroyed

If the engine is destroyed before the program, the program
must be invalidated; otherwise the program destructor will
access a stale engine pointer, which can cause a crash
(it crashes on Symbian, but "only" gives a Valgrind warning
on Linux for our autotests).

We need to keep track of all associated programs, just like
we already do for values and strings. This fix follows the
exact same pattern, but uses a QSet to keep the patch minimal.

No new tests, but the evaluateProgram() test runs successfully
on Symbian now, and there are no more Valgrind warnings.

Task-number: QTBUG-16987
Reviewed-by: Olivier Goffart
(cherry picked from commit b127b1036ec75c625920a6c029b64a95e3702bf9)
src/script/api/qscriptengine.cpp
src/script/api/qscriptengine_p.h
src/script/api/qscriptprogram.cpp
src/script/api/qscriptprogram_p.h