From 50067e3361db39278e54d90777c9ae4491e53b2e Mon Sep 17 00:00:00 2001 From: Kalila L Date: Sun, 25 Oct 2020 18:36:20 -0400 Subject: [PATCH 1/2] Prevent crash on entity-script-server for due to logging interface. --- libraries/script-engine/src/ScriptEngine.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libraries/script-engine/src/ScriptEngine.cpp b/libraries/script-engine/src/ScriptEngine.cpp index c5c6c1fef11..b3b0b26293b 100644 --- a/libraries/script-engine/src/ScriptEngine.cpp +++ b/libraries/script-engine/src/ScriptEngine.cpp @@ -130,6 +130,11 @@ static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine) { // This message was sent by one of our script engines, let's try to see if we can find the source. // Note that the first entry in the backtrace should be "print" and is somewhat useless to us AbstractLoggerInterface* loggerInterface = AbstractLoggerInterface::get(); + if (!loggerInterface) { + qCDebug(scriptengine_script, "%s", qUtf8Printable(message)); + return QScriptValue(); + } + if (loggerInterface->showSourceDebugging()) { QScriptContext* userContext = context; while (userContext && QScriptContextInfo(userContext).functionType() == QScriptContextInfo::NativeFunction) { From 4b2c71cf6175e7d07b805c44fb91c010ff6dc836 Mon Sep 17 00:00:00 2001 From: kasenvr <52365539+kasenvr@users.noreply.github.com> Date: Sun, 25 Oct 2020 19:49:59 -0400 Subject: [PATCH 2/2] Update libraries/script-engine/src/ScriptEngine.cpp Co-authored-by: David Rowe --- libraries/script-engine/src/ScriptEngine.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/libraries/script-engine/src/ScriptEngine.cpp b/libraries/script-engine/src/ScriptEngine.cpp index b3b0b26293b..88c682370c6 100644 --- a/libraries/script-engine/src/ScriptEngine.cpp +++ b/libraries/script-engine/src/ScriptEngine.cpp @@ -130,12 +130,7 @@ static QScriptValue debugPrint(QScriptContext* context, QScriptEngine* engine) { // This message was sent by one of our script engines, let's try to see if we can find the source. // Note that the first entry in the backtrace should be "print" and is somewhat useless to us AbstractLoggerInterface* loggerInterface = AbstractLoggerInterface::get(); - if (!loggerInterface) { - qCDebug(scriptengine_script, "%s", qUtf8Printable(message)); - return QScriptValue(); - } - - if (loggerInterface->showSourceDebugging()) { + if (loggerInterface && loggerInterface->showSourceDebugging()) { QScriptContext* userContext = context; while (userContext && QScriptContextInfo(userContext).functionType() == QScriptContextInfo::NativeFunction) { userContext = userContext->parentContext();