mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 13:09:52 +02:00
update script engine to not treat about:* as a local filename; resolve debugPrint FIXME
This commit is contained in:
parent
8cea7f6a62
commit
e765d8858c
3 changed files with 13 additions and 6 deletions
|
@ -105,11 +105,11 @@ static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine) {
|
||||||
}
|
}
|
||||||
message += context->argument(i).toString();
|
message += context->argument(i).toString();
|
||||||
}
|
}
|
||||||
qCDebug(scriptengineScript).noquote() << "script:print()<<" << message; // noquote() so that \n is treated as newline
|
qCDebug(scriptengineScript).noquote() << message; // noquote() so that \n is treated as newline
|
||||||
|
|
||||||
// FIXME - this approach neeeds revisiting. print() comes here, which ends up calling Script.print?
|
if (ScriptEngine *scriptEngine = qobject_cast<ScriptEngine*>(engine)) {
|
||||||
engine->globalObject().property("Script").property("print")
|
scriptEngine->print(message);
|
||||||
.call(engine->nullValue(), QScriptValueList({ message }));
|
}
|
||||||
|
|
||||||
return QScriptValue();
|
return QScriptValue();
|
||||||
}
|
}
|
||||||
|
@ -472,6 +472,11 @@ void ScriptEngine::scriptInfoMessage(const QString& message) {
|
||||||
emit infoMessage(message, getFilename());
|
emit infoMessage(message, getFilename());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptEngine::scriptPrintedMessage(const QString& message) {
|
||||||
|
qCDebug(scriptengine) << message;
|
||||||
|
emit printedMessage(message, getFilename());
|
||||||
|
}
|
||||||
|
|
||||||
// Even though we never pass AnimVariantMap directly to and from javascript, the queued invokeMethod of
|
// Even though we never pass AnimVariantMap directly to and from javascript, the queued invokeMethod of
|
||||||
// callAnimationStateHandler requires that the type be registered.
|
// callAnimationStateHandler requires that the type be registered.
|
||||||
// These two are meaningful, if we ever do want to use them...
|
// These two are meaningful, if we ever do want to use them...
|
||||||
|
|
|
@ -221,6 +221,7 @@ public:
|
||||||
void scriptErrorMessage(const QString& message);
|
void scriptErrorMessage(const QString& message);
|
||||||
void scriptWarningMessage(const QString& message);
|
void scriptWarningMessage(const QString& message);
|
||||||
void scriptInfoMessage(const QString& message);
|
void scriptInfoMessage(const QString& message);
|
||||||
|
void scriptPrintedMessage(const QString& message);
|
||||||
|
|
||||||
int getNumRunningEntityScripts() const;
|
int getNumRunningEntityScripts() const;
|
||||||
bool getEntityScriptDetails(const EntityItemID& entityID, EntityScriptDetails &details) const;
|
bool getEntityScriptDetails(const EntityItemID& entityID, EntityScriptDetails &details) const;
|
||||||
|
|
|
@ -453,7 +453,8 @@ ScriptEngine* ScriptEngines::loadScript(const QUrl& scriptFilename, bool isUserL
|
||||||
(scriptFilename.scheme() != "http" &&
|
(scriptFilename.scheme() != "http" &&
|
||||||
scriptFilename.scheme() != "https" &&
|
scriptFilename.scheme() != "https" &&
|
||||||
scriptFilename.scheme() != "atp" &&
|
scriptFilename.scheme() != "atp" &&
|
||||||
scriptFilename.scheme() != "file")) {
|
scriptFilename.scheme() != "file" &&
|
||||||
|
scriptFilename.scheme() != "about")) {
|
||||||
// deal with a "url" like c:/something
|
// deal with a "url" like c:/something
|
||||||
scriptUrl = normalizeScriptURL(QUrl::fromLocalFile(scriptFilename.toString()));
|
scriptUrl = normalizeScriptURL(QUrl::fromLocalFile(scriptFilename.toString()));
|
||||||
} else {
|
} else {
|
||||||
|
@ -472,7 +473,7 @@ ScriptEngine* ScriptEngines::loadScript(const QUrl& scriptFilename, bool isUserL
|
||||||
}, Qt::QueuedConnection);
|
}, Qt::QueuedConnection);
|
||||||
|
|
||||||
|
|
||||||
if (scriptFilename.isEmpty()) {
|
if (scriptFilename.isEmpty() || !scriptUrl.isValid()) {
|
||||||
launchScriptEngine(scriptEngine);
|
launchScriptEngine(scriptEngine);
|
||||||
} else {
|
} else {
|
||||||
// connect to the appropriate signals of this script engine
|
// connect to the appropriate signals of this script engine
|
||||||
|
|
Loading…
Reference in a new issue