diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-03-28 08:02:46 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-04-08 20:43:23 +0200 |
commit | 14dc8218eeebd1583e6bd3c49013b3e501f47228 (patch) | |
tree | 387778ceddd2165ab033c742e5c0eff583a6327a /src/imagesprite.h | |
parent | de442e7b15a52729ba37946e74f2799804a77dab (diff) | |
download | mana-14dc8218eeebd1583e6bd3c49013b3e501f47228.tar.gz mana-14dc8218eeebd1583e6bd3c49013b3e501f47228.tar.bz2 mana-14dc8218eeebd1583e6bd3c49013b3e501f47228.tar.xz mana-14dc8218eeebd1583e6bd3c49013b3e501f47228.zip |
Use ResourceRef<Image> 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.
Diffstat (limited to 'src/imagesprite.h')
-rw-r--r-- | src/imagesprite.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/imagesprite.h b/src/imagesprite.h index 5a04f9ed..4fc69927 100644 --- a/src/imagesprite.h +++ b/src/imagesprite.h @@ -60,8 +60,13 @@ public: int getDuration() const override { return 0; } + // Hack to allow the ImageSprite to be used with SubImage instances, which + // are not reference counted. + void releaseImageRef() + { mImage.release(); } + private: - Image *mImage; + ResourceRef<Image> mImage; }; #endif // IMAGESPRITE_H |