Fixes problems associated with node 10 and NAN (#14847)

* Fixes problems associated with node 10 and NAN

* Follow up removal of unnecessary linking to map object

* Remove header left over from debugging
This commit is contained in:
Blake Thompson
2019-06-26 13:38:06 -05:00
committed by GitHub
parent 012ccecaa4
commit a16c67d953
4 changed files with 60 additions and 53 deletions

View File

@@ -544,7 +544,9 @@ void NodeMap::renderFinished() {
},
img.data.get()
).ToLocalChecked();
img.data.release();
if (!pixels.IsEmpty()) {
img.data.release();
}
v8::Local<v8::Value> argv[] = {
Nan::Null(),
@@ -1244,20 +1246,19 @@ std::unique_ptr<mbgl::AsyncRequest> NodeFileSource::request(const mbgl::Resource
// *this while we're still executing code.
nodeMap->handle();
auto asyncRequest = std::make_unique<node_mbgl::NodeAsyncRequest>();
v8::Local<v8::Value> argv[] = {
Nan::New<v8::External>(nodeMap),
Nan::New<v8::External>(&callback_)
Nan::New<v8::External>(&callback_),
Nan::New<v8::External>(asyncRequest.get()),
Nan::New(resource.url).ToLocalChecked(),
Nan::New<v8::Integer>(resource.kind)
};
auto instance = Nan::NewInstance(Nan::New(node_mbgl::NodeRequest::constructor), 2, argv).ToLocalChecked();
Nan::NewInstance(Nan::New(node_mbgl::NodeRequest::constructor), 5, argv).ToLocalChecked();
Nan::Set(instance, Nan::New("url").ToLocalChecked(), Nan::New(resource.url).ToLocalChecked());
Nan::Set(instance, Nan::New("kind").ToLocalChecked(), Nan::New<v8::Integer>(resource.kind));
auto req = Nan::ObjectWrap::Unwrap<node_mbgl::NodeRequest>(instance);
req->Execute();
return std::make_unique<node_mbgl::NodeRequest::NodeAsyncRequest>(req);
return asyncRequest;
}
} // namespace node_mbgl