diff --git a/src/CanvasGradient.cc b/src/CanvasGradient.cc index 2a05f68..ebebf8b 100644 --- a/src/CanvasGradient.cc +++ b/src/CanvasGradient.cc @@ -15,12 +15,12 @@ void Gradient::Initialize(Handle target) { HandleScope scope; - Local t = FunctionTemplate::New(Gradient::New); - t->InstanceTemplate()->SetInternalFieldCount(1); - t->SetClassName(String::NewSymbol("CanvasGradient")); + constructor = Persistent::New(FunctionTemplate::New(Gradient::New)); + constructor->InstanceTemplate()->SetInternalFieldCount(1); + constructor->SetClassName(String::NewSymbol("CanvasGradient")); - NODE_SET_PROTOTYPE_METHOD(t, "addColorStopRGBA", AddColorStopRGBA); - target->Set(String::NewSymbol("CanvasGradient"), t->GetFunction()); + NODE_SET_PROTOTYPE_METHOD(constructor, "addColorStopRGBA", AddColorStopRGBA); + target->Set(String::NewSymbol("CanvasGradient"), constructor->GetFunction()); } /* diff --git a/src/CanvasGradient.h b/src/CanvasGradient.h index 07fecb2..8c0ca6e 100644 --- a/src/CanvasGradient.h +++ b/src/CanvasGradient.h @@ -18,6 +18,7 @@ class Gradient: public node::ObjectWrap { Gradient(double x0, double y0, double x1, double y1); Gradient(double x0, double y0, double r0, double x1, double y1, double r1); inline cairo_pattern_t *pattern(){ return _pattern; } + static Persistent constructor; private: ~Gradient();