From 181ecd0c3bf27b47487f973fb83b988fd6ceaecf Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 2 Mar 2013 21:17:13 +0300 Subject: Another fixes after Coverity checks. --- src/gui/inventorywindow.cpp | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) (limited to 'src/gui/inventorywindow.cpp') diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index 9f6fda689..fe51018bf 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -311,7 +311,7 @@ void InventoryWindow::action(const gcn::ActionEvent &event) mItems->setName(mNameFilter->getText()); mItems->updateMatrix(); } - else if (!eventId.find("tag_") && mItems) + else if (!eventId.find("tag_")) { std::string tagName = event.getId().substr(4); mItems->setFilter(ItemDB::getTagId(tagName)); @@ -398,8 +398,7 @@ void InventoryWindow::unselectItem() void InventoryWindow::widgetHidden(const gcn::Event &event) { Window::widgetHidden(event); - if (mItems) - mItems->hidePopup(); + mItems->hidePopup(); } void InventoryWindow::mouseClicked(gcn::MouseEvent &event) @@ -590,16 +589,19 @@ void InventoryWindow::updateButtons(const Item *item) if (mDropButton) mDropButton->setEnabled(true); - if (mUseButton && item && item->isEquipment()) + if (mUseButton) { - if (item->isEquipped()) - mUseButton->setCaption(_("Unequip")); + if (item && item->isEquipment()) + { + if (item->isEquipped()) + mUseButton->setCaption(_("Unequip")); + else + mUseButton->setCaption(_("Equip")); + } else - mUseButton->setCaption(_("Equip")); - } - else - { - mUseButton->setCaption(_("Use")); + { + mUseButton->setCaption(_("Use")); + } } updateDropButton(); @@ -674,8 +676,7 @@ void InventoryWindow::slotsChanged(Inventory *const inventory) } mSlotsBar->setText(strprintf("%d/%d", usedSlots, maxSlots)); - if (mItems) - mItems->updateMatrix(); + mItems->updateMatrix(); } } @@ -690,15 +691,12 @@ void InventoryWindow::updateDropButton() } else { - if (mItems) - { - const Item *const item = mItems->getSelectedItem(); + const Item *const item = mItems->getSelectedItem(); - if (item && item->getQuantity() > 1) - mDropButton->setCaption(_("Drop...")); - else - mDropButton->setCaption(_("Drop")); - } + if (item && item->getQuantity() > 1) + mDropButton->setCaption(_("Drop...")); + else + mDropButton->setCaption(_("Drop")); } } -- cgit v1.2.3-60-g2f50