From 6d97cdf25db274a81e9d9edc417b51cf44152733 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 2 Jun 2011 18:41:23 +0300 Subject: Fix some memory leaks and missing initialisations. --- src/gui/minimap.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/gui/minimap.cpp') 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; } } -- cgit v1.2.3-60-g2f50