summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-01-29 16:41:27 +0300
committerAndrei Karas <akaras@inbox.ru>2012-01-29 16:41:27 +0300
commit14226518bf85a73b1cc2f5290df5f593ad170be1 (patch)
tree1427e44d7c0f0688a9a44341d2f24b987a2d872b
parentdb068ff16aa689c180037af831d9ba6fca7594d7 (diff)
downloadmv-14226518bf85a73b1cc2f5290df5f593ad170be1.tar.gz
mv-14226518bf85a73b1cc2f5290df5f593ad170be1.tar.bz2
mv-14226518bf85a73b1cc2f5290df5f593ad170be1.tar.xz
mv-14226518bf85a73b1cc2f5290df5f593ad170be1.zip
Fix memory leak after last commit.
-rw-r--r--src/compoundsprite.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp
index 3c16ff540..61fb3d4e0 100644
--- a/src/compoundsprite.cpp
+++ b/src/compoundsprite.cpp
@@ -61,8 +61,7 @@ CompoundSprite::CompoundSprite() :
CompoundSprite::~CompoundSprite()
{
- delete_all(mSprites);
- mSprites.clear();
+ clear();
// delete mImage;
mImage = nullptr;
@@ -123,9 +122,6 @@ bool CompoundSprite::draw(Graphics *graphics, int posX, int posY) const
if (mSprites.empty()) // Nothing to draw
return false;
-// posX += mOffsetX;
-// posY += mOffsetY;
-
if (mAlpha == 1.0f && mImage)
{
return graphics->drawImage(mImage, posX + mOffsetX, posY + mOffsetY);
@@ -286,11 +282,11 @@ void CompoundSprite::removeSprite(int layer)
void CompoundSprite::clear()
{
// Skip if it won't change anything
- if (mSprites.empty())
- return;
-
- delete_all(mSprites);
- mSprites.clear();
+ if (!mSprites.empty())
+ {
+ delete_all(mSprites);
+ mSprites.clear();
+ }
mNeedsRedraw = true;
delete_all(imagesCache);
imagesCache.clear();