summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-02-07 17:10:39 -0700
committerJared Adams <jaxad0127@gmail.com>2010-02-07 17:10:39 -0700
commited39c71b2b6b47931f352ca07b49f631d6bf713a (patch)
treeb66630214ae3b84aa5e8cb910c2801b2a610012b
parentdca3a657c821925b6a3d6776e7cdcb35608989fe (diff)
downloadmana-ed39c71b2b6b47931f352ca07b49f631d6bf713a.tar.gz
mana-ed39c71b2b6b47931f352ca07b49f631d6bf713a.tar.bz2
mana-ed39c71b2b6b47931f352ca07b49f631d6bf713a.tar.xz
mana-ed39c71b2b6b47931f352ca07b49f631d6bf713a.zip
Cleanup some memory issues
-rw-r--r--src/gui/serverdialog.cpp4
-rw-r--r--src/gui/setup_video.cpp2
-rw-r--r--src/gui/updatewindow.cpp3
-rw-r--r--src/gui/widgets/dropdown.cpp4
-rw-r--r--src/gui/widgets/dropdown.h2
-rw-r--r--src/gui/widgets/listbox.cpp13
-rw-r--r--src/gui/widgets/listbox.h6
-rw-r--r--src/net/download.cpp6
8 files changed, 31 insertions, 9 deletions
diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp
index 07f23c0a..b5cd5366 100644
--- a/src/gui/serverdialog.cpp
+++ b/src/gui/serverdialog.cpp
@@ -227,7 +227,11 @@ ServerDialog::ServerDialog(ServerInfo *serverInfo, const std::string &dir):
ServerDialog::~ServerDialog()
{
if (mDownload)
+ {
mDownload->cancel();
+ delete mDownload;
+ mDownload = 0;
+ }
delete mServersListModel;
delete mTypeListModel;
}
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 4a5a1d9a..9c6c8dad 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -236,7 +236,7 @@ Setup_Video::Setup_Video():
particleDetailLabel = new Label(_("Particle detail"));
fontSizeLabel = new Label(_("Font size"));
- mFontSizeDropDown = new DropDown(new FontSizeChoiceListModel);
+ mFontSizeDropDown = new DropDown(new FontSizeChoiceListModel, true);
mModeList->setEnabled(true);
diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp
index 508148e6..85a14ba8 100644
--- a/src/gui/updatewindow.cpp
+++ b/src/gui/updatewindow.cpp
@@ -180,6 +180,9 @@ UpdaterWindow::~UpdaterWindow()
if (mDownload)
{
mDownload->cancel();
+
+ delete mDownload;
+ mDownload = 0;
}
free(mMemoryBuffer);
}
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index b8f5b895..80c3747e 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -43,10 +43,10 @@ Image *DropDown::buttons[2][2];
ImageRect DropDown::skin;
float DropDown::mAlpha = 1.0;
-DropDown::DropDown(gcn::ListModel *listModel):
+DropDown::DropDown(gcn::ListModel *listModel, bool deleteModel):
gcn::DropDown::DropDown(listModel,
new ScrollArea,
- new ListBox(listModel))
+ new ListBox(listModel, deleteModel))
{
setFrameSize(2);
diff --git a/src/gui/widgets/dropdown.h b/src/gui/widgets/dropdown.h
index f4ab4c93..eda7b1fa 100644
--- a/src/gui/widgets/dropdown.h
+++ b/src/gui/widgets/dropdown.h
@@ -45,7 +45,7 @@ class DropDown : public gcn::DropDown
* @param listBox the listBox to use.
* @see ListModel, ScrollArea, ListBox.
*/
- DropDown(gcn::ListModel *listModel = NULL);
+ DropDown(gcn::ListModel *listModel = NULL, bool deleteModel = false);
~DropDown();
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp
index 7f96ad3e..e97f1d63 100644
--- a/src/gui/widgets/listbox.cpp
+++ b/src/gui/widgets/listbox.cpp
@@ -34,11 +34,20 @@
float ListBox::mAlpha = 1.0;
-ListBox::ListBox(gcn::ListModel *listModel):
- gcn::ListBox(listModel)
+ListBox::ListBox(gcn::ListModel *listModel, bool deleteModel):
+ gcn::ListBox(listModel),
+ mDeleteModel(deleteModel)
{
}
+ListBox::~ListBox()
+{
+ if (mDeleteModel)
+ {
+ delete mListModel;
+ }
+}
+
void ListBox::updateAlpha()
{
float alpha = std::max(config.getValue("guialpha", 0.8),
diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h
index d5798d66..c0662ed2 100644
--- a/src/gui/widgets/listbox.h
+++ b/src/gui/widgets/listbox.h
@@ -39,7 +39,9 @@ class ListBox : public gcn::ListBox
/**
* Constructor.
*/
- ListBox(gcn::ListModel *listModel);
+ ListBox(gcn::ListModel *listModel, bool deleteModel = false);
+
+ ~ListBox();
/**
* Draws the list box.
@@ -65,6 +67,8 @@ class ListBox : public gcn::ListBox
private:
static float mAlpha;
+
+ bool mDeleteModel;
};
#endif
diff --git a/src/net/download.cpp b/src/net/download.cpp
index d722d9b7..d5903551 100644
--- a/src/net/download.cpp
+++ b/src/net/download.cpp
@@ -79,10 +79,12 @@ Download::Download(void *ptr, const std::string &url,
Download::~Download()
{
- delete mError;
-
if (mHeaders)
curl_slist_free_all(mHeaders);
+
+ int status;
+ SDL_WaitThread(mThread, &status);
+ free(mError);
}
void Download::addHeader(const std::string &header)