Permalink
Browse files

Fixed leak for {get,create}ImageData

  • Loading branch information...
phoboslab committed Oct 14, 2012
1 parent 20f9fb6 commit 07aa55345bddf2f80f77258f3f57320e4db8f6e8
Showing with 4 additions and 3 deletions.
  1. +4 −0 Classes/Ejecta/EJCanvas/EJBindingCanvas.m
  2. +0 −3 Classes/Ejecta/EJCanvas/EJBindingImageData.m
@@ -382,12 +382,14 @@ - (EJTexture *)texture {
// Create the JS object
JSClassRef imageDataClass = [[EJApp instance] getJSClassForClass:[EJBindingImageData class]];
JSObjectRef obj = JSObjectMake( ctx, imageDataClass, NULL );
+ JSValueProtect(ctx, obj);
// Create the native instance
EJBindingImageData * jsImageData = [[EJBindingImageData alloc] initWithContext:ctx object:obj imageData:imageData];
// Attach the native instance to the js object
JSObjectSetPrivate( obj, (void *)jsImageData );
+ JSValueUnprotect(ctx, obj);
return obj;
}
@@ -404,12 +406,14 @@ - (EJTexture *)texture {
// Create the JS object
JSClassRef imageDataClass = [[EJApp instance] getJSClassForClass:[EJBindingImageData class]];
JSObjectRef obj = JSObjectMake( ctx, imageDataClass, NULL );
+ JSValueProtect(ctx, obj);
// Create the native instance
EJBindingImageData * jsImageData = [[EJBindingImageData alloc] initWithContext:ctx object:obj imageData:imageData];
// Attach the native instance to the js object
JSObjectSetPrivate( obj, (void *)jsImageData );
+ JSValueUnprotect(ctx, obj);
return obj;
}
@@ -5,17 +5,14 @@ @implementation EJBindingImageData
- (id)initWithContext:(JSContextRef)ctx object:(JSObjectRef)obj imageData:(EJImageData *)data {
if( self = [super initWithContext:ctx object:obj argc:0 argv:NULL] ) {
- JSValueProtect(ctx, jsObject);
imageData = [data retain];
-
dataArray = NULL;
}
return self;
}
- (void)dealloc {
JSContextRef ctx = [EJApp instance].jsGlobalContext;
- JSValueUnprotect(ctx, jsObject);
if( dataArray ) {
JSValueUnprotect(ctx, dataArray);
}

0 comments on commit 07aa553

Please sign in to comment.