mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 17:01:18 +02:00
Cleanup and better error handling
This commit is contained in:
parent
e9fac38bbb
commit
3340211455
1 changed files with 4 additions and 6 deletions
|
@ -428,10 +428,7 @@ QString ScriptEngine::getFilename() const {
|
||||||
bool ScriptEngine::hasValidScriptSuffix(const QString& scriptFileName) {
|
bool ScriptEngine::hasValidScriptSuffix(const QString& scriptFileName) {
|
||||||
QFileInfo fileInfo(scriptFileName);
|
QFileInfo fileInfo(scriptFileName);
|
||||||
QString scriptSuffixToLower = fileInfo.completeSuffix().toLower();
|
QString scriptSuffixToLower = fileInfo.completeSuffix().toLower();
|
||||||
if (scriptSuffixToLower == "js" || scriptSuffixToLower == "json") {
|
return ((scriptSuffixToLower == "js") || (scriptSuffixToLower == "json"));
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptEngine::loadURL(const QUrl& scriptURL, bool reload) {
|
void ScriptEngine::loadURL(const QUrl& scriptURL, bool reload) {
|
||||||
|
@ -443,9 +440,10 @@ void ScriptEngine::loadURL(const QUrl& scriptURL, bool reload) {
|
||||||
_fileNameString = url.toString();
|
_fileNameString = url.toString();
|
||||||
_isReloading = reload;
|
_isReloading = reload;
|
||||||
|
|
||||||
// Check that script is an actual script
|
// Check that script has a supported file extension
|
||||||
if (!hasValidScriptSuffix(_fileNameString)) {
|
if (!hasValidScriptSuffix(_fileNameString)) {
|
||||||
qCDebug(scriptengine) << "File extension of file: " + _fileNameString + " is not a currently supported script type";
|
scriptErrorMessage("File extension of file: " + _fileNameString + " is not a currently supported script type");
|
||||||
|
emit errorLoadingScript(_fileNameString);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue