From 14dc8218eeebd1583e6bd3c49013b3e501f47228 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Thu, 28 Mar 2024 08:02:46 +0100 Subject: Use ResourceRef in more places Automatic reference counting of images is now used by Item, Icon, AnimatedSprite, ImageSprite, ParticleEmitter, Minimap, Desktop and Emote. Since ResourceManager::get automatically adds a reference, it needs to be explicitly subtracted when the resource is managed by ResourceRef. This is taken care of by the new ResourceManager::getImageRef. Also removed the apprently unused and duplicate "mDrawImage" from Item (which also didn't get decRef called on it). Fixes cleanup of emote ImageSet and ImageSprite instances, as well as particle images. --- src/animatedsprite.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src/animatedsprite.cpp') diff --git a/src/animatedsprite.cpp b/src/animatedsprite.cpp index 6a5800aa..7aa475d9 100644 --- a/src/animatedsprite.cpp +++ b/src/animatedsprite.cpp @@ -35,9 +35,6 @@ AnimatedSprite::AnimatedSprite(SpriteDef *sprite): { assert(mSprite); - // Take possession of the sprite - mSprite->incRef(); - // Play the stand animation by default play(SpriteAction::STAND); } @@ -53,10 +50,7 @@ AnimatedSprite *AnimatedSprite::load(const std::string &filename, int variant) return as; } -AnimatedSprite::~AnimatedSprite() -{ - mSprite->decRef(); -} +AnimatedSprite::~AnimatedSprite() = default; bool AnimatedSprite::reset() { -- cgit v1.2.3-70-g09d2