summaryrefslogtreecommitdiff
path: root/src/gui/windows
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/windows')
-rw-r--r--src/gui/windows/buydialog.cpp13
-rw-r--r--src/gui/windows/chatwindow.cpp21
-rw-r--r--src/gui/windows/minimap.cpp2
-rw-r--r--src/gui/windows/skilldialog.cpp2
-rw-r--r--src/gui/windows/statuswindow.cpp2
-rw-r--r--src/gui/windows/textdialog.cpp16
6 files changed, 25 insertions, 31 deletions
diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp
index 3b3657272..84a7a1182 100644
--- a/src/gui/windows/buydialog.cpp
+++ b/src/gui/windows/buydialog.cpp
@@ -488,6 +488,8 @@ void BuyDialog::action(const ActionEvent &event)
else if (eventId == "buy" && mAmountItems > 0 && mAmountItems <= mMaxItems)
{
ShopItem *const item = mShopItems->at(selectedItem);
+ if (!item)
+ return;
if (mNpcId == fromInt(Items, BeingId))
{
adminHandler->createItems(item->getId(),
@@ -544,13 +546,10 @@ void BuyDialog::action(const ActionEvent &event)
if (tradeWindow)
#endif
{
- if (item)
- {
- buySellHandler->sendBuyRequest(mNick,
- item, mAmountItems);
- tradeWindow->addAutoMoney(mNick,
- item->getPrice() * mAmountItems);
- }
+ buySellHandler->sendBuyRequest(mNick,
+ item, mAmountItems);
+ tradeWindow->addAutoMoney(mNick,
+ item->getPrice() * mAmountItems);
}
}
}
diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp
index 3f26cc4dc..f7a101a44 100644
--- a/src/gui/windows/chatwindow.cpp
+++ b/src/gui/windows/chatwindow.cpp
@@ -692,11 +692,11 @@ void ChatWindow::mousePressed(MouseEvent &event)
{
if (popupMenu)
{
- Tab *const tab = mChatTabs->getSelectedTab();
- if (tab)
+ ChatTab *const cTab = dynamic_cast<ChatTab*>(
+ mChatTabs->getSelectedTab());
+ if (cTab)
{
event.consume();
- ChatTab *const cTab = dynamic_cast<ChatTab*>(tab);
if (inputManager.isActionActive(InputAction::CHAT_MOD))
{
inputManager.executeChatCommand(
@@ -2163,11 +2163,14 @@ void ChatWindow::showGMTab()
void ChatWindow::joinRoom(const bool isJoin)
{
Tab *const tab = mChatTabs->getTabByIndex(0);
- std::string name;
- if (isJoin)
- name = PlayerInfo::getRoomName();
- else
- name = _("General");
- tab->setCaption(name);
+ if (tab)
+ {
+ std::string name;
+ if (isJoin)
+ name = PlayerInfo::getRoomName();
+ else
+ name = _("General");
+ tab->setCaption(name);
+ }
}
#endif
diff --git a/src/gui/windows/minimap.cpp b/src/gui/windows/minimap.cpp
index 9e2cb4b81..502ebf91a 100644
--- a/src/gui/windows/minimap.cpp
+++ b/src/gui/windows/minimap.cpp
@@ -393,7 +393,7 @@ void Minimap::draw2(Graphics *const graphics)
const PartyMember *const m = party->getMember(
localPlayer->getName());
const Party::MemberList *const members = party->getMembers();
- if (m && members)
+ if (m)
{
const std::string curMap = m->getMap();
Party::MemberList::const_iterator it = members->begin();
diff --git a/src/gui/windows/skilldialog.cpp b/src/gui/windows/skilldialog.cpp
index 8997220f1..89b614e8d 100644
--- a/src/gui/windows/skilldialog.cpp
+++ b/src/gui/windows/skilldialog.cpp
@@ -337,7 +337,7 @@ void SkillDialog::loadXmlFile(const std::string &fileName)
? 0 : XML::getProperty(node, "level", 0);
SkillData *data = skill->getData(level);
if (!data)
- data = new SkillData();
+ data = new SkillData;
data->name = name;
data->setIcon(icon);
diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp
index ed7438736..5f8df4ef7 100644
--- a/src/gui/windows/statuswindow.cpp
+++ b/src/gui/windows/statuswindow.cpp
@@ -633,7 +633,7 @@ std::string StatusWindow::translateLetter(const char *const letters)
{
char buf[2];
char *const str = gettext(letters);
- if (strlen(str) != 3)
+ if (!str || strlen(str) != 3)
return letters;
buf[0] = str[1];
diff --git a/src/gui/windows/textdialog.cpp b/src/gui/windows/textdialog.cpp
index 642d574cc..0d74c95e5 100644
--- a/src/gui/windows/textdialog.cpp
+++ b/src/gui/windows/textdialog.cpp
@@ -68,18 +68,10 @@ TextDialog::TextDialog(const std::string &restrict title,
place(2, 2, mOkButton);
place(3, 2, cancelButton);
- const Font *const font = getFont();
- if (font)
- {
- int width = font->getWidth(title);
- if (width < textLabel->getWidth())
- width = textLabel->getWidth();
- reflowLayout(static_cast<int>(width + 20));
- }
- else
- {
- reflowLayout(static_cast<int>(textLabel->getWidth() + 20));
- }
+ int width = getFont()->getWidth(title);
+ if (width < textLabel->getWidth())
+ width = textLabel->getWidth();
+ reflowLayout(static_cast<int>(width + 20));
}
void TextDialog::postInit()