Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work around crash when logging warnings #248

Merged
merged 1 commit into from
Jul 30, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
}