Allow .pragma library scripts to import other scripts
authorChris Adams <christopher.adams@nokia.com>
Fri, 23 Sep 2011 01:58:39 +0000 (11:58 +1000)
committerQt by Nokia <qt-info@nokia.com>
Mon, 3 Oct 2011 23:25:05 +0000 (01:25 +0200)
commit4c01174b63e049eeb945081e1e6cc7b09514fc6b
treecc3a555a7bc7e19cab2b80a20b74e6c823813def
parent61e7c0b9383998525f5df39a3596eb0cf39a270d
Allow .pragma library scripts to import other scripts

Previously, a .pragma library script would have a new context which
did not have an engine set.  If the script then imported other scripts
a crash would occur due to dereferencing the (null) engine ptr.

This commit ensures that even if no parent context is used (eg, for
shared scripts which don't import the parent context) the engine from
the parent context is used as the engine in the new context.

Finally, unit tests for the .pragma library import with imports cases
were added to tst_qdeclarativeecmascript.

Task-number: QTBUG-21620
Change-Id: I671ffc9eee98a69cce7c169ce5b9d5aae4d1ff0d
Reviewed-on: http://codereview.qt-project.org/5421
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
src/declarative/qml/qdeclarativevme.cpp
tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibraryWithImports.js [new file with mode: 0644]
tests/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibraryWithPragmaLibraryImports.js [new file with mode: 0644]
tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibraryWithImports.qml [new file with mode: 0644]
tests/auto/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml [new file with mode: 0644]
tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp