Skip to content

Commit

Permalink
Merge pull request #248 from NativeScript/fealebenpae/fix-warn-in-boo…
Browse files Browse the repository at this point in the history
…tstrap

Work around crash when logging warnings
  • Loading branch information
fealebenpae committed Jul 30, 2015
1 parent 32a3b01 commit 1cfa85f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/NativeScript/JSWarnings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,24 @@
#include <JavaScriptCore/ScriptValue.h>
#include <JavaScriptCore/ScriptArguments.h>
#include <JavaScriptCore/ConsoleClient.h>
#include <JavaScriptCore/JSGlobalObjectConsoleClient.h>

namespace NativeScript {
using namespace JSC;

void warn(ExecState* execState, const WTF::String& message) {
bool restoreLogToSystemConsole = false;
if (!execState->vm().topCallFrame && Inspector::JSGlobalObjectConsoleClient::logToSystemConsole()) {
WTFLogAlways("CONSOLE WARN %s", message.utf8().data());
Inspector::JSGlobalObjectConsoleClient::setLogToSystemConsole(false);
restoreLogToSystemConsole = true;
}

WTF::Vector<Deprecated::ScriptValue> arguments{ Deprecated::ScriptValue(execState->vm(), jsString(execState, message)) };
execState->lexicalGlobalObject()->consoleClient()->logWithLevel(execState, Inspector::ScriptArguments::create(execState, arguments), MessageLevel::Warning);

if (restoreLogToSystemConsole) {
Inspector::JSGlobalObjectConsoleClient::setLogToSystemConsole(true);
}
}
}

0 comments on commit 1cfa85f

Please sign in to comment.