summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/shopwindow.cpp4
-rw-r--r--src/gui/widgets/shopitems.cpp10
-rw-r--r--src/gui/widgets/shopitems.h7
3 files changed, 19 insertions, 2 deletions
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();