Skip to content

Commit

Permalink
napi: Fix weakref callback for wrap (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasongin authored Mar 1, 2017
1 parent 26adcc2 commit 75e28c5
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/node_jsvmapi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,12 @@ namespace v8impl {
_finalizeCallback(finalizeCallback),
_finalizeData(finalizeData) {
if (initialRefcount == 0) {
_persistent.SetWeak(this, FinalizeCallback, v8::WeakCallbackType::kParameter);
if (_finalizeCallback != nullptr || _deleteSelf) {
_persistent.SetWeak(this, FinalizeCallback, v8::WeakCallbackType::kParameter);
}
else {
_persistent.SetWeak();
}
_persistent.MarkIndependent();
}
}
Expand All @@ -172,7 +177,12 @@ namespace v8impl {

int Release() {
if (--_refcount == 0) {
_persistent.SetWeak(this, FinalizeCallback, v8::WeakCallbackType::kParameter);
if (_finalizeCallback != nullptr || _deleteSelf) {
_persistent.SetWeak(this, FinalizeCallback, v8::WeakCallbackType::kParameter);
}
else {
_persistent.SetWeak();
}
_persistent.MarkIndependent();
}

Expand Down Expand Up @@ -721,7 +731,7 @@ napi_status napi_define_class(
}

napi_status status = napi_define_properties(
e, *result, staticDescriptors.size(), staticDescriptors.data());
e, *result, static_cast<int>(staticDescriptors.size()), staticDescriptors.data());
if (status != napi_ok) return status;
}

Expand Down

0 comments on commit 75e28c5

Please sign in to comment.