summaryrefslogtreecommitdiff
path: root/src/gui/windows
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-04-22 21:54:59 +0300
committerAndrei Karas <akaras@inbox.ru>2014-04-22 21:54:59 +0300
commitbcd95847a435bb3aab90bdb3c2fdada6063efc2e (patch)
tree9a9cb19d2cec9c73d3b8c9eaeb4c781b0ac48642 /src/gui/windows
parentff6c93b16f408a2ef10e47a4168c59ab6c4fdafb (diff)
downloadmanaplus-bcd95847a435bb3aab90bdb3c2fdada6063efc2e.tar.gz
manaplus-bcd95847a435bb3aab90bdb3c2fdada6063efc2e.tar.bz2
manaplus-bcd95847a435bb3aab90bdb3c2fdada6063efc2e.tar.xz
manaplus-bcd95847a435bb3aab90bdb3c2fdada6063efc2e.zip
Fix crash if start trade with opened storage.
Diffstat (limited to 'src/gui/windows')
-rw-r--r--src/gui/windows/inventorywindow.cpp17
-rw-r--r--src/gui/windows/inventorywindow.h2
2 files changed, 18 insertions, 1 deletions
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp
index c2a4b4636..01e5e052d 100644
--- a/src/gui/windows/inventorywindow.cpp
+++ b/src/gui/windows/inventorywindow.cpp
@@ -271,7 +271,8 @@ void InventoryWindow::postInit()
InventoryWindow::~InventoryWindow()
{
invInstances.remove(this);
- mInventory->removeInventoyListener(this);
+ if (mInventory)
+ mInventory->removeInventoyListener(this);
if (!invInstances.empty())
invInstances.front()->updateDropButton();
@@ -681,7 +682,10 @@ void InventoryWindow::close()
else
{
if (Net::getInventoryHandler())
+ {
Net::getInventoryHandler()->closeStorage(Inventory::STORAGE);
+ Net::getInventoryHandler()->forgotStorage();
+ }
scheduleDelete();
}
}
@@ -806,3 +810,14 @@ void InventoryWindow::setVisible(bool visible)
mSortDropDown->hideDrop();
Window::setVisible(visible);
}
+
+void InventoryWindow::unsetInventory()
+{
+ if (mInventory)
+ {
+ mInventory->removeInventoyListener(this);
+ if (mItems)
+ mItems->unsetInventory();
+ }
+ mInventory = nullptr;
+}
diff --git a/src/gui/windows/inventorywindow.h b/src/gui/windows/inventorywindow.h
index 7e47e0362..10e1e21e2 100644
--- a/src/gui/windows/inventorywindow.h
+++ b/src/gui/windows/inventorywindow.h
@@ -152,6 +152,8 @@ class InventoryWindow final : public Window,
void setVisible(bool visible) override final;
+ void unsetInventory();
+
static bool isAnyInputFocused();
private: