mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
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:
@@ -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();
|
||||
|
||||
@@ -176,8 +176,9 @@ void SpriteBatch::unlock()
|
||||
|
||||
void SpriteBatch::setImage(Image *newimage)
|
||||
{
|
||||
Object::AutoRelease imagerelease(image);
|
||||
|
||||
newimage->retain();
|
||||
image->release();
|
||||
image = newimage;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user