summaryrefslogtreecommitdiff
path: root/src/gui
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
parent6b83725f3acf5a1e4dd08f4f243609fc66a38c22 (diff)
downloadplus-6d97cdf25db274a81e9d9edc417b51cf44152733.tar.gz
plus-6d97cdf25db274a81e9d9edc417b51cf44152733.tar.bz2
plus-6d97cdf25db274a81e9d9edc417b51cf44152733.tar.xz
plus-6d97cdf25db274a81e9d9edc417b51cf44152733.zip
Fix some memory leaks and missing initialisations.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/minimap.cpp18
-rw-r--r--src/gui/minimap.h1
-rw-r--r--src/gui/whoisonline.cpp5
-rw-r--r--src/gui/widgets/button.cpp7
4 files changed, 26 insertions, 5 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;
}
}
diff --git a/src/gui/minimap.h b/src/gui/minimap.h
index e75dfddc1..33e0f14ee 100644
--- a/src/gui/minimap.h
+++ b/src/gui/minimap.h
@@ -63,6 +63,7 @@ class Minimap : public Window
float mWidthProportion;
float mHeightProportion;
static bool mShow;
+ bool mCustomMapImage;
};
extern Minimap *minimap;
diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp
index dfb896778..73b6e2e8c 100644
--- a/src/gui/whoisonline.cpp
+++ b/src/gui/whoisonline.cpp
@@ -368,6 +368,7 @@ int WhoIsOnline::downloadThread(void *ptr)
if (!wio->mAllowUpdate)
{
curl_easy_cleanup(curl);
+ curl = 0;
break;
}
wio->mDownloadedBytes = 0;
@@ -410,11 +411,13 @@ int WhoIsOnline::downloadThread(void *ptr)
break;
}
attempts++;
+ curl_easy_cleanup(curl);
+ curl_slist_free_all(pHeaders);
+ curl = 0;
continue;
}
curl_easy_cleanup(curl);
-
curl_slist_free_all(pHeaders);
// It's stored in memory, we're done
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index ba3ac5f36..0bc5ec9ef 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -71,6 +71,7 @@ ImageRect Button::button[BUTTON_COUNT];
Button::Button():
mDescription(""), mClickCount(0),
+ mTag(0),
mVertexes(new GraphicsVertexes()),
mRedraw(true),
mMode(0),
@@ -84,8 +85,12 @@ Button::Button(const std::string &caption, const std::string &actionEventId,
gcn::ActionListener *listener):
gcn::Button(caption),
mDescription(""), mClickCount(0),
+ mTag(0),
mVertexes(new GraphicsVertexes()),
- mRedraw(true)
+ mRedraw(true),
+ mMode(0),
+ mXOffset(0),
+ mYOffset(0)
{
init();
setActionEventId(actionEventId);