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:
parent
ede0a39b5b
commit
f45e182d33
4 changed files with 21 additions and 2 deletions
7
examples/example/tests/test-includes/a.js
Normal file
7
examples/example/tests/test-includes/a.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
// a.js:
|
||||
Script.include('b.js');
|
||||
if (a === undefined) {
|
||||
a = 0;
|
||||
}
|
||||
a++;
|
||||
print('script a:' + a);
|
6
examples/example/tests/test-includes/b.js
Normal file
6
examples/example/tests/test-includes/b.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
// b.js:
|
||||
if (b === undefined) {
|
||||
b = 0;
|
||||
}
|
||||
b++;
|
||||
print('script b: ' + b);
|
5
examples/example/tests/test-includes/start.js
Normal file
5
examples/example/tests/test-includes/start.js
Normal 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);
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue