Skip to content

Commit

Permalink
Fix assertion failure when using VSCode debugger to inspect Image proto
Browse files Browse the repository at this point in the history
GetSource and SetSource are sort of weird plain functions that require
the `this` context to be an Image instance.

Fixes Automattic#1534
  • Loading branch information
zbjornson committed Apr 6, 2020
1 parent c025143 commit 6991561
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
* Fix BMP issues. (#1497)
* Update typings to support jpg and addPage on NodeCanvasRenderingContext2D (#1509)
* Fix assertion failure when using Visual Studio Code debugger to inspect Image prototype (#1534)

2.6.1
==================
Expand Down
10 changes: 10 additions & 0 deletions src/Image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ NAN_SETTER(Image::SetHeight) {
*/

NAN_METHOD(Image::GetSource){
if (!Image::constructor.Get(info.GetIsolate())->HasInstance(info.This())) {
// #1534
Nan::ThrowTypeError("Method Image.GetSource called on incompatible receiver");
return;
}
Image *img = Nan::ObjectWrap::Unwrap<Image>(info.This());
info.GetReturnValue().Set(Nan::New<String>(img->filename ? img->filename : "").ToLocalChecked());
}
Expand Down Expand Up @@ -227,6 +232,11 @@ Image::clearData() {
*/

NAN_METHOD(Image::SetSource){
if (!Image::constructor.Get(info.GetIsolate())->HasInstance(info.This())) {
// #1534
Nan::ThrowTypeError("Method Image.SetSource called on incompatible receiver");
return;
}
Image *img = Nan::ObjectWrap::Unwrap<Image>(info.This());
cairo_status_t status = CAIRO_STATUS_READ_ERROR;

Expand Down

0 comments on commit 6991561

Please sign in to comment.