3
0
Fork 0
mirror of https://github.com/JulianGro/overte.git synced 2025-04-29 21:03:17 +02:00

fix CR feedback, add examples

This commit is contained in:
Brad Hefta-Gaub 2015-09-10 09:06:56 -07:00
parent ede0a39b5b
commit f45e182d33
4 changed files with 21 additions and 2 deletions
examples/example/tests/test-includes
libraries/script-engine/src

View file

@ -0,0 +1,7 @@
// a.js:
Script.include('b.js');
if (a === undefined) {
a = 0;
}
a++;
print('script a:' + a);

View file

@ -0,0 +1,6 @@
// b.js:
if (b === undefined) {
b = 0;
}
b++;
print('script b: ' + b);

View file

@ -0,0 +1,5 @@
// start.js:
var a, b;
print('initially: a:' + a + ' b:' + b);
Script.include(['a.js', '../test-includes/a.js', 'b.js', 'a.js']);
print('finally a:' + a + ' b:' + b);

View file

@ -863,7 +863,9 @@ void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callbac
QUrl thisURL { resolvePath(file) };
if (!_includedURLs.contains(thisURL)) {
urls.append(thisURL);
} else {
_includedURLs << thisURL;
}
else {
qCDebug(scriptengine) << "Script.include() ignoring previously included url:" << thisURL;
}
}
@ -876,7 +878,6 @@ void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callbac
if (contents.isNull()) {
qCDebug(scriptengine) << "Error loading file: " << url << "line:" << __LINE__;
} else {
_includedURLs << url;
QScriptValue result = evaluate(contents, url.toString());
}
}