Skip to content

Commit

Permalink
keep file path information in exceptions during qml parse
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelvasev committed Aug 1, 2015
1 parent f869b53 commit bae9d88
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/parser.js
Expand Up @@ -279,6 +279,7 @@ function JS_Parse_Error(message, line, col, pos, comment) {
this.col = col;
this.pos = pos;
this.comment = comment ? comment : "";
this.file = nowParsingFile;
try {
({})();
} catch(ex) {
Expand Down Expand Up @@ -1772,7 +1773,9 @@ function convertToEngine(tree) {
}

// Function to parse qml and output tree expected by engine
function parseQML(src) {
var nowParsingFile = "";
function parseQML(src, file) {
nowParsingFile = file;
var parsetree = qmlparse(src);
return convertToEngine(parsetree);
}
6 changes: 3 additions & 3 deletions src/qtcore.js
Expand Up @@ -175,7 +175,7 @@ constructors = {
// mix of engine.loadQML and Loader.qml
Qt.createQmlObject = function( src, parent, file )
{
var tree = parseQML(src);
var tree = parseQML(src, file);

// Create and initialize objects
var component = new QMLComponent({ object: tree, parent: parent });
Expand Down Expand Up @@ -245,7 +245,7 @@ Qt.createComponent = function(name, executionContext)
if (src === false)
return undefined;

var tree = parseQML(src);
var tree = parseQML(src, file);

if (tree.$children.length !== 1)
console.error("A QML component must only contain one root element!");
Expand Down Expand Up @@ -1033,7 +1033,7 @@ QMLEngine = function (element, options) {
// parse and construct qml
this.loadQML = function(src,file) { // file is not required; only for debug purposes
engine = this;
var tree = parseQML(src);
var tree = parseQML(src, file);
if (options.debugTree) {
options.debugTree(tree);
}
Expand Down

0 comments on commit bae9d88

Please sign in to comment.