Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Chris Adams
authored and
Qt by Nokia
committed
Oct 3, 2011
1 parent
61e7c0b
commit 4c01174
Showing
6 changed files
with
153 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...s/auto/declarative/qdeclarativeecmascript/data/jsimport/importPragmaLibraryWithImports.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.pragma library | ||
.import "importFive.js" as ImportFive | ||
|
||
var i = 4; | ||
|
||
function importIncrementedValue() { | ||
i = i + 1; | ||
return (i + ImportFive.importFiveFunction()); // i + '5' (not i+5) | ||
} |
11 changes: 11 additions & 0 deletions
11
...ative/qdeclarativeecmascript/data/jsimport/importPragmaLibraryWithPragmaLibraryImports.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.pragma library | ||
.import "importPragmaLibrary.js" as LibraryImport | ||
|
||
var i = 10; | ||
|
||
function importIncrementedValue() { | ||
i = i + 1; | ||
// because LibraryImport is shared, and used in previous tests, | ||
// the value will be large (already incremented a bunch of times). | ||
return (i + LibraryImport.importIncrementedValue()); | ||
} |
7 changes: 7 additions & 0 deletions
7
...o/declarative/qdeclarativeecmascript/data/jsimport/testImportPragmaLibraryWithImports.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import QtQuick 2.0 | ||
import "importPragmaLibraryWithImports.js" as LibraryImport | ||
|
||
QtObject { | ||
id: root | ||
property int testValue: LibraryImport.importIncrementedValue(); // valueOf(4 + 1 + '5') = valueOf('55') = 55 | ||
} |
7 changes: 7 additions & 0 deletions
7
.../qdeclarativeecmascript/data/jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import QtQuick 2.0 | ||
import "importPragmaLibraryWithPragmaLibraryImports.js" as LibraryImport | ||
|
||
QtObject { | ||
id: root | ||
property int testValue: LibraryImport.importIncrementedValue(); // 10 + 1 + (7 due to previous tests) = 18 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters