diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-04-22 21:54:59 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-04-22 21:54:59 +0300 |
commit | bcd95847a435bb3aab90bdb3c2fdada6063efc2e (patch) | |
tree | 9a9cb19d2cec9c73d3b8c9eaeb4c781b0ac48642 /src | |
parent | ff6c93b16f408a2ef10e47a4168c59ab6c4fdafb (diff) | |
download | plus-bcd95847a435bb3aab90bdb3c2fdada6063efc2e.tar.gz plus-bcd95847a435bb3aab90bdb3c2fdada6063efc2e.tar.bz2 plus-bcd95847a435bb3aab90bdb3c2fdada6063efc2e.tar.xz plus-bcd95847a435bb3aab90bdb3c2fdada6063efc2e.zip |
Fix crash if start trade with opened storage.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/widgets/itemcontainer.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/itemcontainer.h | 3 | ||||
-rw-r--r-- | src/gui/windows/inventorywindow.cpp | 17 | ||||
-rw-r--r-- | src/gui/windows/inventorywindow.h | 2 | ||||
-rw-r--r-- | src/net/ea/inventoryhandler.cpp | 11 | ||||
-rw-r--r-- | src/net/ea/inventoryhandler.h | 2 | ||||
-rw-r--r-- | src/net/inventoryhandler.h | 2 |
7 files changed, 37 insertions, 2 deletions
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index ee2e35920..f24be7737 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -507,7 +507,7 @@ void ItemContainer::mouseReleased(MouseEvent &event) Net::getInventoryHandler()->moveItem(mSelectedIndex, index); selectNone(); } - else + else if (mInventory) { const DragDropSource src = dragDrop.getSource(); DragDropSource dst = DRAGDROP_SOURCE_EMPTY; diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index f7bc44849..06e9fd459 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -131,6 +131,9 @@ class ItemContainer final : public Widget, bool getClickCount() const A_WARN_UNUSED { return mClicks; } + void unsetInventory() + { mInventory = nullptr; } + private: enum Direction { 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: diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index f3c8040e1..ea7390ccb 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -486,6 +486,11 @@ void InventoryHandler::processPlayerStorageClose(Net::MessageIn &msg A_UNUSED) { // Storage access has been closed // Storage window deletes itself + if (mStorageWindow) + { + mStorageWindow->unsetInventory(); + mStorageWindow->close(); + } mStorageWindow = nullptr; if (mStorage) @@ -592,9 +597,15 @@ void InventoryHandler::closeStorage() { if (mStorageWindow) { + mStorageWindow->unsetInventory(); mStorageWindow->close(); mStorageWindow = nullptr; } } +void InventoryHandler::forgotStorage() +{ + mStorageWindow = nullptr; +} + } // namespace Ea diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h index ac88c1d6c..4546b75bb 100644 --- a/src/net/ea/inventoryhandler.h +++ b/src/net/ea/inventoryhandler.h @@ -210,6 +210,8 @@ class InventoryHandler : public Net::InventoryHandler void closeStorage() override final; + void forgotStorage() override final; + Inventory *getStorage() const { return mStorage; } diff --git a/src/net/inventoryhandler.h b/src/net/inventoryhandler.h index 53e7d15b1..42649bae6 100644 --- a/src/net/inventoryhandler.h +++ b/src/net/inventoryhandler.h @@ -71,6 +71,8 @@ class InventoryHandler virtual void closeStorage() = 0; + virtual void forgotStorage() = 0; + virtual int convertFromServerSlot(const int eAthenaSlot) const = 0; }; |