diff --git a/src/Image.cc b/src/Image.cc index 35206b8..6b71116 100644 --- a/src/Image.cc +++ b/src/Image.cc @@ -17,18 +17,18 @@ void Image::Initialize(Handle target) { HandleScope scope; - Local t = FunctionTemplate::New(Image::New); - t->InstanceTemplate()->SetInternalFieldCount(1); - t->SetClassName(String::NewSymbol("Image")); + constructor = Persistent::New(FunctionTemplate::New(Image::New)); + constructor->InstanceTemplate()->SetInternalFieldCount(1); + constructor->SetClassName(String::NewSymbol("Image")); - Local proto = t->PrototypeTemplate(); + Local proto = constructor->PrototypeTemplate(); proto->SetAccessor(String::NewSymbol("src"), GetSrc, SetSrc); proto->SetAccessor(String::NewSymbol("complete"), GetComplete); proto->SetAccessor(String::NewSymbol("width"), GetWidth); proto->SetAccessor(String::NewSymbol("height"), GetHeight); proto->SetAccessor(String::NewSymbol("onload"), GetOnload, SetOnload); proto->SetAccessor(String::NewSymbol("onerror"), GetOnerror, SetOnerror); - target->Set(String::NewSymbol("Image"), t->GetFunction()); + target->Set(String::NewSymbol("Image"), constructor->GetFunction()); } /* diff --git a/src/Image.h b/src/Image.h index 3f3b789..11ac495 100644 --- a/src/Image.h +++ b/src/Image.h @@ -36,6 +36,7 @@ class Image: public node::ObjectWrap { void loaded(); void load(); Image(); + static Persistent constructor; enum { DEFAULT