diff options
author | Blake Thompson <blake@mapbox.com> | 2019-06-06 16:47:22 -0500 |
---|---|---|
committer | Blake Thompson <blake@mapbox.com> | 2019-06-26 10:47:34 -0500 |
commit | 0d48f95f522ba78fb553b0993a48580177d5ba5e (patch) | |
tree | 1e3c684929d868d06bb272009d8393c98e2b6b75 | |
parent | f2bf7a7e971cee0addf07620e247cc1697610360 (diff) | |
download | qtlocation-mapboxgl-0d48f95f522ba78fb553b0993a48580177d5ba5e.tar.gz |
Follow up removal of unnecessary linking to map object
-rw-r--r-- | platform/node/src/node_map.cpp | 12 | ||||
-rw-r--r-- | platform/node/src/node_map.hpp | 2 | ||||
-rw-r--r-- | platform/node/src/node_request.cpp | 18 | ||||
-rw-r--r-- | platform/node/src/node_request.hpp | 4 |
4 files changed, 12 insertions, 24 deletions
diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp index 805750b3b1..e59982ad99 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -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(), @@ -647,14 +649,6 @@ void NodeMap::cancel() { renderFinished(); } -void NodeMap::ref() { - Ref(); -} - -void NodeMap::unref() { - Unref(); -} - void NodeMap::AddSource(const Nan::FunctionCallbackInfo<v8::Value>& info) { using namespace mbgl::style; using namespace mbgl::style::conversion; diff --git a/platform/node/src/node_map.hpp b/platform/node/src/node_map.hpp index 52cb3fdc28..486754c1c3 100644 --- a/platform/node/src/node_map.hpp +++ b/platform/node/src/node_map.hpp @@ -71,8 +71,6 @@ public: void release(); void cancel(); - void ref(); - void unref(); static RenderOptions ParseOptions(v8::Local<v8::Object>); diff --git a/platform/node/src/node_request.cpp b/platform/node/src/node_request.cpp index 28618ec6a5..6bf5b8cef8 100644 --- a/platform/node/src/node_request.cpp +++ b/platform/node/src/node_request.cpp @@ -5,14 +5,14 @@ #include <cmath> +#include <iostream> + namespace node_mbgl { NodeRequest::NodeRequest( - NodeMap * target_, mbgl::FileSource::Callback callback_, NodeAsyncRequest* asyncRequest_) - : target(target_), - callback(std::move(callback_)), + : callback(std::move(callback_)), asyncRequest(asyncRequest_) { asyncRequest->request = this; } @@ -44,13 +44,12 @@ void NodeRequest::New(const Nan::FunctionCallbackInfo<v8::Value>& info) { auto callback = reinterpret_cast<mbgl::FileSource::Callback*>(info[1].As<v8::External>()->Value()); auto asyncRequest = reinterpret_cast<NodeAsyncRequest*>(info[2].As<v8::External>()->Value()); - auto request = new NodeRequest(target, *callback, asyncRequest); + auto request = new NodeRequest(*callback, asyncRequest); request->Wrap(info.This()); request->Ref(); Nan::Set(info.This(), Nan::New("url").ToLocalChecked(), info[3]); Nan::Set(info.This(), Nan::New("kind").ToLocalChecked(), info[4]); - target->ref(); v8::Local<v8::Value> argv[] = { info.This() }; request->asyncResource->runInAsyncScope(Nan::To<v8::Object>(target->handle()->GetInternalField(1)).ToLocalChecked(), "request", 1, argv); info.GetReturnValue().Set(info.This()); @@ -61,9 +60,9 @@ void NodeRequest::HandleCallback(const Nan::FunctionCallbackInfo<v8::Value>& inf // Move out of the object so callback() can only be fired once. auto callback = std::move(request->callback); + request->callback = {}; if (!callback) { request->unref(); - request->target->unref(); return info.GetReturnValue().SetUndefined(); } @@ -88,7 +87,6 @@ void NodeRequest::HandleCallback(const Nan::FunctionCallbackInfo<v8::Value>& inf ); } else if (info.Length() < 2 || !info[1]->IsObject()) { request->unref(); - request->target->unref(); return Nan::ThrowTypeError("Second argument must be a response object"); } else { auto res = Nan::To<v8::Object>(info[1]).ToLocalChecked(); @@ -123,7 +121,6 @@ void NodeRequest::HandleCallback(const Nan::FunctionCallbackInfo<v8::Value>& inf ); } else { request->unref(); - request->target->unref(); return Nan::ThrowTypeError("Response data must be a Buffer"); } } @@ -132,7 +129,6 @@ void NodeRequest::HandleCallback(const Nan::FunctionCallbackInfo<v8::Value>& inf // Send the response object to the NodeFileSource object callback(response); request->unref(); - request->target->unref(); info.GetReturnValue().SetUndefined(); } @@ -149,7 +145,9 @@ NodeAsyncRequest::~NodeAsyncRequest() { if (request) { // Remove the callback function because the AsyncRequest was // canceled and we are no longer interested in the result. - request->callback = {}; + if (request->callback) { + request->callback = {}; + } request->asyncRequest = nullptr; } } diff --git a/platform/node/src/node_request.hpp b/platform/node/src/node_request.hpp index de663a88f3..830d262b40 100644 --- a/platform/node/src/node_request.hpp +++ b/platform/node/src/node_request.hpp @@ -11,7 +11,6 @@ namespace node_mbgl { -class NodeMap; class NodeRequest; struct NodeAsyncRequest : public mbgl::AsyncRequest { @@ -24,7 +23,7 @@ class NodeRequest : public Nan::ObjectWrap { public: - NodeRequest(NodeMap*, mbgl::FileSource::Callback, NodeAsyncRequest*); + NodeRequest(mbgl::FileSource::Callback, NodeAsyncRequest*); ~NodeRequest(); static Nan::Persistent<v8::Function> constructor; @@ -36,7 +35,6 @@ public: void unref(); - NodeMap * target; mbgl::FileSource::Callback callback; NodeAsyncRequest* asyncRequest; Nan::AsyncResource* asyncResource = new Nan::AsyncResource("mbgl:execute"); |