diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-06-02 18:41:23 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-06-02 23:00:56 +0300 |
commit | 6d97cdf25db274a81e9d9edc417b51cf44152733 (patch) | |
tree | 142f1cc00b1733bb54980a863932c96c7a98fa73 /src/gui/minimap.cpp | |
parent | 6b83725f3acf5a1e4dd08f4f243609fc66a38c22 (diff) | |
download | mv-6d97cdf25db274a81e9d9edc417b51cf44152733.tar.gz mv-6d97cdf25db274a81e9d9edc417b51cf44152733.tar.bz2 mv-6d97cdf25db274a81e9d9edc417b51cf44152733.tar.xz mv-6d97cdf25db274a81e9d9edc417b51cf44152733.zip |
Fix some memory leaks and missing initialisations.
Diffstat (limited to 'src/gui/minimap.cpp')
-rw-r--r-- | src/gui/minimap.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index b85826679..32887466c 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -49,7 +49,8 @@ Minimap::Minimap(): Window(_("Map")), mMapImage(0), mWidthProportion(0.5), - mHeightProportion(0.5) + mHeightProportion(0.5), + mCustomMapImage(false) { setWindowName("Minimap"); mShow = config.getValueBool(getWindowName() + "Show", true); @@ -74,7 +75,13 @@ Minimap::~Minimap() config.setValue(getWindowName() + "Show", mShow); if (mMapImage) - mMapImage->decRef(); + { + if (mCustomMapImage) + delete mMapImage; + else + mMapImage->decRef(); + mMapImage = 0; + } } void Minimap::setMap(Map *map) @@ -93,7 +100,10 @@ void Minimap::setMap(Map *map) // Adapt the image if (mMapImage) { - mMapImage->decRef(); + if (mCustomMapImage) + delete mMapImage; + else + mMapImage->decRef(); mMapImage = 0; } @@ -129,6 +139,7 @@ void Minimap::setMap(Map *map) mMapImage = Image::load(surface); mMapImage->setAlpha(Client::getGuiAlpha()); + mCustomMapImage = true; SDL_FreeSurface(surface); } else @@ -143,6 +154,7 @@ void Minimap::setMap(Map *map) minimapName = tempname; mMapImage = resman->getImage(minimapName); + mCustomMapImage = false; } } |