Skip to content

Commit ec01ee7

Browse files
committed
fix a persistent static handle in NumericCasts
1 parent 8822658 commit ec01ee7

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

runtime/src/main/jni/NumericCasts.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,13 @@ void NumericCasts::CreateGlobalCastFunctions(Isolate *isolate, const Local<Objec
2121
globalTemplate->Set(ArgConverter::ConvertToV8String(isolate, "double"), FunctionTemplate::New(isolate, NumericCasts::MarkAsDoubleCallbackStatic, ext));
2222
globalTemplate->Set(ArgConverter::ConvertToV8String(isolate, "float"), FunctionTemplate::New(isolate, NumericCasts::MarkAsFloatCallbackStatic, ext));
2323
globalTemplate->Set(ArgConverter::ConvertToV8String(isolate, "char"), FunctionTemplate::New(isolate, NumericCasts::MarkAsCharCallbackStatic, ext));
24-
25-
s_castMarker = new Persistent<String>(isolate, ArgConverter::ConvertToV8String(isolate, "t::cast"));
2624
}
2725

2826
CastType NumericCasts::GetCastType(const Local<Object>& object)
2927
{
3028
auto ret = CastType::None;
3129
auto isolate = object->GetIsolate();
32-
auto key = Local<String>::New(isolate, *s_castMarker);
30+
auto key = ArgConverter::ConvertToV8String(isolate, s_castMarker);
3331
auto hidden = object->GetHiddenValue(key);
3432
if (!hidden.IsEmpty())
3533
{
@@ -456,12 +454,12 @@ void NumericCasts::MarkAsDoubleCallback(const v8::FunctionCallbackInfo<Value>& a
456454
void NumericCasts::MarkJsObject(const Local<Object>& object, CastType castType, const Local<Value>& value)
457455
{
458456
auto isolate = object->GetIsolate();
459-
auto key = Local<String>::New(isolate, *s_castMarker);
457+
auto key = ArgConverter::ConvertToV8String(isolate, s_castMarker);
460458
auto type = Integer::New(isolate, static_cast<int>(castType));
461459

462460
object->SetHiddenValue(key, type);
463461
object->Set(V8StringConstants::GetValue(isolate), value);
464462
DEBUG_WRITE("MarkJsObject: Marking js object: %d with cast type: %d", object->GetIdentityHash(), castType);
465463
}
466464

467-
Persistent<String> *NumericCasts::s_castMarker = nullptr;
465+
std::string NumericCasts::s_castMarker = "t::cast";

runtime/src/main/jni/NumericCasts.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ namespace tns
5757

5858
static NumericCasts* GetThis(const v8::FunctionCallbackInfo<v8::Value>& args);
5959

60-
static v8::Persistent<v8::String> *s_castMarker;
60+
static std::string s_castMarker;
6161
};
6262
}
6363

runtime/src/main/jni/Runtime.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,9 @@ Isolate* Runtime::PrepareV8Runtime(const string& filesPath, jstring packageName,
436436

437437
V8::SetFlagsFromString(Constants::V8_STARTUP_FLAGS.c_str(), Constants::V8_STARTUP_FLAGS.size());
438438
V8::SetCaptureStackTraceForUncaughtExceptions(true, 100, StackTrace::kOverview);
439-
V8::AddMessageListener(NativeScriptException::OnUncaughtError);
439+
440+
isolate->AddMessageListener(NativeScriptException::OnUncaughtError);
441+
440442
__android_log_print(ANDROID_LOG_DEBUG, "TNS.Native", "V8 version %s", V8::GetVersion());
441443

442444
auto globalTemplate = ObjectTemplate::New();

0 commit comments

Comments
 (0)