mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 01:03:38 +02:00
quiet warning flood when scripts are bad
This commit is contained in:
parent
31072b2b2e
commit
a88b3c02d2
3 changed files with 22 additions and 4 deletions
|
@ -166,7 +166,10 @@ QString EntityTreeRenderer::loadScriptContents(const QString& scriptMaybeURLorTe
|
|||
}
|
||||
} else {
|
||||
auto scriptCache = DependencyManager::get<ScriptCache>();
|
||||
scriptContents = scriptCache->getScript(url, this, isPending);
|
||||
|
||||
if (!scriptCache->isInBadScriptList(url)) {
|
||||
scriptContents = scriptCache->getScript(url, this, isPending);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -216,6 +219,12 @@ QScriptValue EntityTreeRenderer::loadEntityScript(EntityItem* entity, bool isPre
|
|||
_waitingOnPreload.insert(url, entityID);
|
||||
|
||||
}
|
||||
|
||||
auto scriptCache = DependencyManager::get<ScriptCache>();
|
||||
|
||||
if (isURL && scriptCache->isInBadScriptList(url)) {
|
||||
return QScriptValue(); // no script contents...
|
||||
}
|
||||
|
||||
if (scriptContents.isEmpty()) {
|
||||
return QScriptValue(); // no script contents...
|
||||
|
@ -227,6 +236,9 @@ QScriptValue EntityTreeRenderer::loadEntityScript(EntityItem* entity, bool isPre
|
|||
qDebug() << " " << syntaxCheck.errorMessage() << ":"
|
||||
<< syntaxCheck.errorLineNumber() << syntaxCheck.errorColumnNumber();
|
||||
qDebug() << " SCRIPT:" << entityScript;
|
||||
|
||||
scriptCache->addScriptToBadScriptList(url);
|
||||
|
||||
return QScriptValue(); // invalid script
|
||||
}
|
||||
|
||||
|
@ -239,6 +251,9 @@ QScriptValue EntityTreeRenderer::loadEntityScript(EntityItem* entity, bool isPre
|
|||
qDebug() << "EntityTreeRenderer::loadEntityScript() entity:" << entityID;
|
||||
qDebug() << " NOT CONSTRUCTOR";
|
||||
qDebug() << " SCRIPT:" << entityScript;
|
||||
|
||||
scriptCache->addScriptToBadScriptList(url);
|
||||
|
||||
return QScriptValue(); // invalid script
|
||||
} else {
|
||||
entityScriptConstructor = _entitiesScriptEngine->evaluate(scriptContents);
|
||||
|
|
|
@ -27,6 +27,8 @@ class ScriptCache : public QObject, public Dependency {
|
|||
|
||||
public:
|
||||
QString getScript(const QUrl& url, ScriptUser* scriptUser, bool& isPending);
|
||||
void addScriptToBadScriptList(const QUrl& url) { _badScripts.insert(url); }
|
||||
bool isInBadScriptList(const QUrl& url) { return _badScripts.contains(url); }
|
||||
|
||||
private slots:
|
||||
void scriptDownloaded();
|
||||
|
@ -36,6 +38,7 @@ private:
|
|||
|
||||
QHash<QUrl, QString> _scriptCache;
|
||||
QMultiMap<QUrl, ScriptUser*> _scriptUsers;
|
||||
QSet<QUrl> _badScripts;
|
||||
};
|
||||
|
||||
#endif // hifi_ScriptCache_h
|
|
@ -276,7 +276,7 @@ void ScriptEngine::loadURL(const QUrl& scriptURL) {
|
|||
_scriptContents = in.readAll();
|
||||
emit scriptLoaded(_fileNameString);
|
||||
} else {
|
||||
qDebug() << "ERROR Loading file:" << _fileNameString;
|
||||
qDebug() << "ERROR Loading file:" << _fileNameString << "line:" << __LINE__;
|
||||
emit errorLoadingScript(_fileNameString);
|
||||
}
|
||||
} else {
|
||||
|
@ -294,7 +294,7 @@ void ScriptEngine::scriptContentsAvailable(const QUrl& url, const QString& scrip
|
|||
}
|
||||
|
||||
void ScriptEngine::errorInLoadingScript(const QUrl& url) {
|
||||
qDebug() << "ERROR Loading file:" << url.toString();
|
||||
qDebug() << "ERROR Loading file:" << url.toString() << "line:" << __LINE__;
|
||||
emit errorLoadingScript(_fileNameString); // ??
|
||||
}
|
||||
|
||||
|
@ -761,7 +761,7 @@ void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callbac
|
|||
for (QUrl url : urls) {
|
||||
QString contents = data[url];
|
||||
if (contents.isNull()) {
|
||||
qDebug() << "Error loading file: " << url;
|
||||
qDebug() << "Error loading file: " << url << "line:" << __LINE__;
|
||||
} else {
|
||||
QScriptValue result = evaluate(contents, url.toString());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue