deref CPImage from dom image to prevent memory leak

This commit is contained in:
Rich Collins authored and Ross Boucher committed 2009-04-04 22:44:21 -07:00
1 parent ecee86cc6d
commit 4cb516d8b1
1 file changed
+11
+11
View File
@@ -219,6 +219,7 @@ function CPImageInBundle(aFilename, aSize, aBundle)
[self _imageDidLoad];
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
}
[self _derefFromImage];
}
_image.onerror = function ()
@@ -230,6 +231,7 @@ function CPImageInBundle(aFilename, aSize, aBundle)
[self _imageDidError];
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
}
[self _derefFromImage];
}
_image.onabort = function ()
@@ -241,6 +243,7 @@ function CPImageInBundle(aFilename, aSize, aBundle)
[self _imageDidAbort];
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
}
[self _derefFromImage];
}
_image.src = _filename;
@@ -258,6 +261,14 @@ function CPImageInBundle(aFilename, aSize, aBundle)
return NO;
}
/* @ignore */
- (void)_derefFromImage
{
_image.onload = null;
_image.onerror = null;
_image.onabort = null;
}
/* @ignore */
- (void)_imageDidLoad
{