Browse Source

Added Image::error()

v1.x
Tj Holowaychuk 14 years ago
parent
commit
77187c2afe
  1. 18
      src/Image.cc
  2. 1
      src/Image.h

18
src/Image.cc

@ -154,8 +154,7 @@ EIO_AfterLoad(eio_req *req) {
Image *img = (Image *) req->data;
if (req->result) {
Local<Value> argv[1] = { Canvas::Error((cairo_status_t) req->result) };
img->onerror->Call(Context::GetCurrent()->Global(), 1, argv);
img->error(Canvas::Error((cairo_status_t) req->result));
} else {
img->loaded();
}
@ -180,16 +179,23 @@ Image::loaded() {
onload->Call(Context::GetCurrent()->Global(), 0, NULL);
onload.Dispose();
if (try_catch.HasCaught()) {
if (!onerror.IsEmpty()) {
Local<Value> argv[1] = { try_catch.Exception() };
onerror->Call(Context::GetCurrent()->Global(), 1, argv);
}
error(try_catch.Exception());
}
}
Unref();
}
void
Image::error(Local<Value> err) {
if (onerror.IsEmpty()) {
// TODO:
} else {
Local<Value> argv[1] = { err };
onerror->Call(Context::GetCurrent()->Global(), 1, argv);
}
}
cairo_status_t
Image::loadSurface() {
_surface = cairo_image_surface_create_from_png(filename);

1
src/Image.h

@ -28,6 +28,7 @@ class Image: public node::ObjectWrap {
static void SetOnerror(Local<String> prop, Local<Value> val, const AccessorInfo &info);
inline cairo_surface_t *surface(){ return _surface; }
cairo_status_t loadSurface();
void error(Local<Value>);
void loaded();
void load();
Image();

Loading…
Cancel
Save