summaryrefslogtreecommitdiff
path: root/src/gui/minimap.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-06-02 18:41:23 +0300
committerAndrei Karas <akaras@inbox.ru>2011-06-02 23:00:56 +0300
commit6d97cdf25db274a81e9d9edc417b51cf44152733 (patch)
tree142f1cc00b1733bb54980a863932c96c7a98fa73 /src/gui/minimap.cpp
parent6b83725f3acf5a1e4dd08f4f243609fc66a38c22 (diff)
downloadManaVerse-6d97cdf25db274a81e9d9edc417b51cf44152733.tar.gz
ManaVerse-6d97cdf25db274a81e9d9edc417b51cf44152733.tar.bz2
ManaVerse-6d97cdf25db274a81e9d9edc417b51cf44152733.tar.xz
ManaVerse-6d97cdf25db274a81e9d9edc417b51cf44152733.zip
Fix some memory leaks and missing initialisations.
Diffstat (limited to 'src/gui/minimap.cpp')
-rw-r--r--src/gui/minimap.cpp18
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;
}
}