Added a way for love's reference-counted objects to be released more safely in some situations (e.g. setters)

This commit is contained in:
Alex Szpakowski
2013-06-09 02:42:33 -03:00
parent f253a016f6
commit 35984790e5
4 changed files with 31 additions and 5 deletions
+1 -2
View File
@@ -543,8 +543,7 @@ Color Graphics::getBackgroundColor() const
void Graphics::setFont(Font *font)
{
if (currentFont != 0)
currentFont->release();
Object::AutoRelease fontrelease(currentFont);
currentFont = font;
@@ -193,8 +193,7 @@ void ParticleSystem::remove(particle *p)
void ParticleSystem::setImage(Image *image)
{
if (this->image != 0)
this->image->release();
Object::AutoRelease imagerelease(this->image);
this->image = image;
this->image->retain();
+2 -1
View File
@@ -176,8 +176,9 @@ void SpriteBatch::unlock()
void SpriteBatch::setImage(Image *newimage)
{
Object::AutoRelease imagerelease(image);
newimage->retain();
image->release();
image = newimage;
}