summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-07-05 22:33:12 +0300
committerAndrei Karas <akaras@inbox.ru>2011-07-05 22:33:12 +0300
commita5e45cef061b921981012176ad7dc9cb5e03dacc (patch)
tree80780eec88ab13b2a05269f70fc84bf3a67780ce
parent710a37891458aaa3b924286950250500fb7b3fc3 (diff)
downloadplus-a5e45cef061b921981012176ad7dc9cb5e03dacc.tar.gz
plus-a5e45cef061b921981012176ad7dc9cb5e03dacc.tar.bz2
plus-a5e45cef061b921981012176ad7dc9cb5e03dacc.tar.xz
plus-a5e45cef061b921981012176ad7dc9cb5e03dacc.zip
Fix memory leak in shop window, add missing initialisation to BeingCacheEntry.
Small code style fix.
-rw-r--r--src/being.cpp4
-rw-r--r--src/gui/shopwindow.cpp4
-rw-r--r--src/gui/widgets/shopitems.cpp10
-rw-r--r--src/gui/widgets/shopitems.h7
-rw-r--r--src/resources/resourcemanager.cpp3
5 files changed, 24 insertions, 4 deletions
diff --git a/src/being.cpp b/src/being.cpp
index acfe9e445..4e4b64061 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -99,7 +99,9 @@ class BeingCacheEntry
mPartyName(""),
mLevel(0),
mPvpRank(0),
- mTime(0)
+ mTime(0),
+ mIp(""),
+ mIsAdvanced(false)
{
}
diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp
index fdfea5d15..c6c41884d 100644
--- a/src/gui/shopwindow.cpp
+++ b/src/gui/shopwindow.cpp
@@ -190,12 +190,12 @@ void ShopWindow::action(const gcn::ActionEvent &event)
else if (event.getId() == "delete buy" && mBuyShopItemList
&& mBuyShopItemList->getSelected() >= 0)
{
- mBuyShopItems->erase(mBuyShopItemList->getSelected());
+ mBuyShopItems->del(mBuyShopItemList->getSelected());
}
else if (event.getId() == "delete sell" && mSellShopItemList
&& mSellShopItemList->getSelected() >= 0)
{
- mSellShopItems->erase(mSellShopItemList->getSelected());
+ mSellShopItems->del(mSellShopItemList->getSelected());
}
else if (event.getId() == "announce buy" && mBuyShopItems
&& mBuyShopItems->getNumberOfElements() > 0)
diff --git a/src/gui/widgets/shopitems.cpp b/src/gui/widgets/shopitems.cpp
index 85ee0a181..c5bcd88c4 100644
--- a/src/gui/widgets/shopitems.cpp
+++ b/src/gui/widgets/shopitems.cpp
@@ -101,6 +101,16 @@ void ShopItems::erase(unsigned int i)
mShopItems.erase(mShopItems.begin() + i);
}
+void ShopItems::del(unsigned int i)
+{
+ if (i >= mShopItems.size())
+ return;
+
+ ShopItem *item = *(mShopItems.begin() + i);
+ mShopItems.erase(mShopItems.begin() + i);
+ delete item;
+}
+
void ShopItems::clear()
{
delete_all(mShopItems);
diff --git a/src/gui/widgets/shopitems.h b/src/gui/widgets/shopitems.h
index cc444fe85..abfcffb71 100644
--- a/src/gui/widgets/shopitems.h
+++ b/src/gui/widgets/shopitems.h
@@ -96,6 +96,13 @@ class ShopItems : public gcn::ListModel
void erase(unsigned int i);
/**
+ * Removes an element from the shop and destroy it.
+ *
+ * @param i index to remove
+ */
+ void del(unsigned int i);
+
+ /**
* Clears the list of items in the shop.
*/
void clear();
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index 78ca6a284..ad188ec1c 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -752,7 +752,8 @@ Image *ResourceManager::getRescaled(Image *image, int width, int height)
if (!image)
return 0;
- std::string idPath = image->getIdPath() + strprintf("_rescaled%dx%d", width, height);
+ std::string idPath = image->getIdPath() + strprintf(
+ "_rescaled%dx%d", width, height);
RescaledLoader l = { this, image, width, height };
Image *img = static_cast<Image*>(get(idPath, RescaledLoader::load, &l));
return img;