@@ -1615,8 +1615,9 @@ void Image::EIO_AfterCopy(uv_work_t* req)
16151615 {
16161616 Image* im = new Image (closure->im2 );
16171617 v8::Local<v8::Value> ext = Nan::New<v8::External>(im);
1618- v8::Local<v8::Object> image_obj = Nan::New (constructor)->GetFunction ()->NewInstance (1 , &ext);
1619- v8::Local<v8::Value> argv[2 ] = { Nan::Null (), image_obj };
1618+ v8::MaybeLocal<v8::Object> maybe_local = Nan::NewInstance (Nan::New (constructor)->GetFunction (), 1 , &ext);
1619+ if (maybe_local.IsEmpty ()) Nan::ThrowError (" Could not create new Image instance" );
1620+ v8::Local<v8::Value> argv[2 ] = { Nan::Null (), maybe_local.ToLocalChecked () };
16201621 Nan::MakeCallback (Nan::GetCurrentContext ()->Global (), Nan::New (closure->cb ), 2 , argv);
16211622 }
16221623 closure->im1 ->Unref ();
@@ -1733,7 +1734,9 @@ v8::Local<v8::Value> Image::_copySync(Nan::NAN_METHOD_ARGS_TYPE info)
17331734 );
17341735 Image* new_im = new Image (imagep);
17351736 v8::Local<v8::Value> ext = Nan::New<v8::External>(new_im);
1736- return scope.Escape (Nan::New (constructor)->GetFunction ()->NewInstance (1 , &ext));
1737+ v8::MaybeLocal<v8::Object> maybe_local = Nan::NewInstance (Nan::New (constructor)->GetFunction (), 1 , &ext);
1738+ if (maybe_local.IsEmpty ()) Nan::ThrowError (" Could not create new Image instance" );
1739+ return scope.Escape (maybe_local.ToLocalChecked ());
17371740 }
17381741 catch (std::exception const & ex)
17391742 {
@@ -2077,8 +2080,9 @@ void Image::EIO_AfterResize(uv_work_t* req)
20772080 {
20782081 Image* im = new Image (closure->im2 );
20792082 v8::Local<v8::Value> ext = Nan::New<v8::External>(im);
2080- v8::Local<v8::Object> image_obj = Nan::New (constructor)->GetFunction ()->NewInstance (1 , &ext);
2081- v8::Local<v8::Value> argv[2 ] = { Nan::Null (), image_obj };
2083+ v8::MaybeLocal<v8::Object> maybe_local = Nan::NewInstance (Nan::New (constructor)->GetFunction (), 1 , &ext);
2084+ if (maybe_local.IsEmpty ()) Nan::ThrowError (" Could not create new Image instance" );
2085+ v8::Local<v8::Value> argv[2 ] = { Nan::Null (), maybe_local.ToLocalChecked () };
20822086 Nan::MakeCallback (Nan::GetCurrentContext ()->Global (), Nan::New (closure->cb ), 2 , argv);
20832087 }
20842088 closure->im1 ->Unref ();
@@ -2263,7 +2267,9 @@ v8::Local<v8::Value> Image::_resizeSync(Nan::NAN_METHOD_ARGS_TYPE info)
22632267 mapnik::util::apply_visitor (visit, *imagep);
22642268 Image* new_im = new Image (imagep);
22652269 v8::Local<v8::Value> ext = Nan::New<v8::External>(new_im);
2266- return scope.Escape (Nan::New (constructor)->GetFunction ()->NewInstance (1 , &ext));
2270+ v8::MaybeLocal<v8::Object> maybe_local = Nan::NewInstance (Nan::New (constructor)->GetFunction (), 1 , &ext);
2271+ if (maybe_local.IsEmpty ()) Nan::ThrowError (" Could not create new Image instance" );
2272+ return scope.Escape (maybe_local.ToLocalChecked ());
22672273 }
22682274 catch (std::exception const & ex)
22692275 {
@@ -2372,7 +2378,9 @@ v8::Local<v8::Value> Image::_openSync(Nan::NAN_METHOD_ARGS_TYPE info)
23722378 }
23732379 Image* im = new Image (imagep);
23742380 v8::Local<v8::Value> ext = Nan::New<v8::External>(im);
2375- return scope.Escape (Nan::New (constructor)->GetFunction ()->NewInstance (1 , &ext));
2381+ v8::MaybeLocal<v8::Object> maybe_local = Nan::NewInstance (Nan::New (constructor)->GetFunction (), 1 , &ext);
2382+ if (maybe_local.IsEmpty ()) Nan::ThrowError (" Could not create new Image instance" );
2383+ return scope.Escape (maybe_local.ToLocalChecked ());
23762384 }
23772385 }
23782386 Nan::ThrowTypeError ((" Unsupported image format:" + filename).c_str ());
@@ -2508,8 +2516,9 @@ void Image::EIO_AfterOpen(uv_work_t* req)
25082516 {
25092517 Image* im = new Image (closure->im );
25102518 v8::Local<v8::Value> ext = Nan::New<v8::External>(im);
2511- v8::Local<v8::Object> image_obj = Nan::New (constructor)->GetFunction ()->NewInstance (1 , &ext);
2512- v8::Local<v8::Value> argv[2 ] = { Nan::Null (), image_obj };
2519+ v8::MaybeLocal<v8::Object> maybe_local = Nan::NewInstance (Nan::New (constructor)->GetFunction (), 1 , &ext);
2520+ if (maybe_local.IsEmpty ()) Nan::ThrowError (" Could not create new Image instance" );
2521+ v8::Local<v8::Value> argv[2 ] = { Nan::Null (), maybe_local.ToLocalChecked () };
25132522 Nan::MakeCallback (Nan::GetCurrentContext ()->Global (), Nan::New (closure->cb ), 2 , argv);
25142523 }
25152524 closure->cb .Reset ();
@@ -2716,7 +2725,9 @@ v8::Local<v8::Value> Image::_fromSVGSync(bool fromFile, Nan::NAN_METHOD_ARGS_TYP
27162725 image_ptr imagep = std::make_shared<mapnik::image_any>(im);
27172726 Image *im2 = new Image (imagep);
27182727 v8::Local<v8::Value> ext = Nan::New<v8::External>(im2);
2719- return scope.Escape (Nan::New (constructor)->GetFunction ()->NewInstance (1 , &ext));
2728+ v8::MaybeLocal<v8::Object> maybe_local = Nan::NewInstance (Nan::New (constructor)->GetFunction (), 1 , &ext);
2729+ if (maybe_local.IsEmpty ()) Nan::ThrowError (" Could not create new Image instance" );
2730+ return scope.Escape (maybe_local.ToLocalChecked ());
27202731 }
27212732 catch (std::exception const & ex)
27222733 {
@@ -2952,8 +2963,9 @@ void Image::EIO_AfterFromSVG(uv_work_t* req)
29522963 {
29532964 Image* im = new Image (closure->im );
29542965 v8::Local<v8::Value> ext = Nan::New<v8::External>(im);
2955- v8::Local<v8::Object> image_obj = Nan::New (constructor)->GetFunction ()->NewInstance (1 , &ext);
2956- v8::Local<v8::Value> argv[2 ] = { Nan::Null (), image_obj };
2966+ v8::MaybeLocal<v8::Object> maybe_local = Nan::NewInstance (Nan::New (constructor)->GetFunction (), 1 , &ext);
2967+ if (maybe_local.IsEmpty ()) Nan::ThrowError (" Could not create new Image instance" );
2968+ v8::Local<v8::Value> argv[2 ] = { Nan::Null (), maybe_local.ToLocalChecked () };
29572969 Nan::MakeCallback (Nan::GetCurrentContext ()->Global (), Nan::New (closure->cb ), 2 , argv);
29582970 }
29592971 closure->cb .Reset ();
@@ -3284,10 +3296,11 @@ v8::Local<v8::Value> Image::_fromBufferSync(Nan::NAN_METHOD_ARGS_TYPE info)
32843296 image_ptr imagep = std::make_shared<mapnik::image_any>(im_wrapper);
32853297 Image* im = new Image (imagep);
32863298 v8::Local<v8::Value> ext = Nan::New<v8::External>(im);
3287- v8::Local<v8::Value> image_instance = Nan::New (constructor)->GetFunction ()->NewInstance (1 , &ext);
3288- v8::Local<v8::Object> image_obj = image_instance->ToObject ();
3299+ v8::MaybeLocal<v8::Object> maybe_local = Nan::NewInstance (Nan::New (constructor)->GetFunction (), 1 , &ext);
3300+ if (maybe_local.IsEmpty ()) Nan::ThrowError (" Could not create new Image instance" );
3301+ v8::Local<v8::Object> image_obj = maybe_local.ToLocalChecked ()->ToObject ();
32893302 image_obj->Set (Nan::New (" _buffer" ).ToLocalChecked (),obj);
3290- return scope.Escape (image_instance );
3303+ return scope.Escape (maybe_local. ToLocalChecked () );
32913304 }
32923305 catch (std::exception const & ex)
32933306 {
@@ -3339,7 +3352,9 @@ v8::Local<v8::Value> Image::_fromBytesSync(Nan::NAN_METHOD_ARGS_TYPE info)
33393352 image_ptr imagep = std::make_shared<mapnik::image_any>(reader->read (0 ,0 ,reader->width (),reader->height ()));
33403353 Image* im = new Image (imagep);
33413354 v8::Local<v8::Value> ext = Nan::New<v8::External>(im);
3342- return scope.Escape (Nan::New (constructor)->GetFunction ()->NewInstance (1 , &ext));
3355+ v8::MaybeLocal<v8::Object> maybe_local = Nan::NewInstance (Nan::New (constructor)->GetFunction (), 1 , &ext);
3356+ if (maybe_local.IsEmpty ()) Nan::ThrowError (" Could not create new Image instance" );
3357+ return scope.Escape (maybe_local.ToLocalChecked ());
33433358 }
33443359 // The only way this is ever reached is if the reader factory in
33453360 // mapnik was not providing an image type it should. This should never
@@ -3508,8 +3523,9 @@ void Image::EIO_AfterFromBytes(uv_work_t* req)
35083523 {
35093524 Image* im = new Image (closure->im );
35103525 v8::Local<v8::Value> ext = Nan::New<v8::External>(im);
3511- v8::Local<v8::Object> image_obj = Nan::New (constructor)->GetFunction ()->NewInstance (1 , &ext);
3512- v8::Local<v8::Value> argv[2 ] = { Nan::Null (), image_obj };
3526+ v8::MaybeLocal<v8::Object> maybe_local = Nan::NewInstance (Nan::New (constructor)->GetFunction (), 1 , &ext);
3527+ if (maybe_local.IsEmpty ()) Nan::ThrowError (" Could not create new Image instance" );
3528+ v8::Local<v8::Value> argv[2 ] = { Nan::Null (), maybe_local.ToLocalChecked () };
35133529 Nan::MakeCallback (Nan::GetCurrentContext ()->Global (), Nan::New (closure->cb ), 2 , argv);
35143530 }
35153531 closure->cb .Reset ();
0 commit comments