diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-07-11 00:12:09 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-07-11 00:12:09 +0300 |
commit | 4fbb944f132eb886a6f5b350e5a14a4fe380aacf (patch) | |
tree | 6df2ed96430610ee7c35a7ca4902bbdade0e8e34 /src/gui/widgets | |
parent | 1dc012a3bb44218778568e8f80c4e9b445802195 (diff) | |
download | manaverse-4fbb944f132eb886a6f5b350e5a14a4fe380aacf.tar.gz manaverse-4fbb944f132eb886a6f5b350e5a14a4fe380aacf.tar.bz2 manaverse-4fbb944f132eb886a6f5b350e5a14a4fe380aacf.tar.xz manaverse-4fbb944f132eb886a6f5b350e5a14a4fe380aacf.zip |
Add missing checks into gui.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/colorpage.cpp | 3 | ||||
-rw-r--r-- | src/gui/widgets/itemcontainer.cpp | 34 | ||||
-rw-r--r-- | src/gui/widgets/label.cpp | 7 | ||||
-rw-r--r-- | src/gui/widgets/listbox.cpp | 5 | ||||
-rw-r--r-- | src/gui/widgets/scrollarea.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/setupitem.h | 2 | ||||
-rw-r--r-- | src/gui/widgets/tabbedarea.cpp | 33 | ||||
-rw-r--r-- | src/gui/widgets/tabs/socialfriendstab.h | 2 | ||||
-rw-r--r-- | src/gui/widgets/tabs/socialnavigationtab.h | 15 | ||||
-rw-r--r-- | src/gui/widgets/tabs/socialplayerstab.h | 6 | ||||
-rw-r--r-- | src/gui/widgets/tabstrip.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/widget.h | 4 | ||||
-rw-r--r-- | src/gui/widgets/window.cpp | 13 |
13 files changed, 54 insertions, 74 deletions
diff --git a/src/gui/widgets/colorpage.cpp b/src/gui/widgets/colorpage.cpp index 6897399d5..d50f49968 100644 --- a/src/gui/widgets/colorpage.cpp +++ b/src/gui/widgets/colorpage.cpp @@ -36,8 +36,7 @@ ColorPage::ColorPage(const Widget2 *const widget, mItemPadding = mSkin ? mSkin->getOption("itemPadding") : 1; mRowHeight = 13; const Font *const font = getFont(); - if (font) - mRowHeight = font->getHeight() + 2 * mItemPadding; + mRowHeight = font->getHeight() + 2 * mItemPadding; if (mListModel) { setHeight(getRowHeight() * mListModel->getNumberOfElements() diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 7e9049aa0..17c0d9cf1 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -616,18 +616,21 @@ void ItemContainer::mouseReleased(MouseEvent &event) #endif { inventory = PlayerInfo::getInventory(); - const Item *const item = inventory->getItem(dragDrop.getTag()); - if (item && !PlayerInfo::isItemProtected(item->getId())) + if (inventory) { - mInventory->addItem(item->getId(), item->getType(), - 1, - 1, - item->getColor(), - item->getIdentified(), - item->getDamaged(), - item->getFavorite(), - Equipm_false, - Equipped_false); + const Item *const item = inventory->getItem(dragDrop.getTag()); + if (item && !PlayerInfo::isItemProtected(item->getId())) + { + mInventory->addItem(item->getId(), item->getType(), + 1, + 1, + item->getColor(), + item->getIdentified(), + item->getDamaged(), + item->getFavorite(), + Equipm_false, + Equipped_false); + } } return; } @@ -638,9 +641,12 @@ void ItemContainer::mouseReleased(MouseEvent &event) #endif { inventory = PlayerInfo::getInventory(); - const Item *const item = inventory->getItem(dragDrop.getTag()); - if (item) - mInventory->removeItemAt(dragDrop.getTag()); + if (inventory) + { + const Item *const item = inventory->getItem(dragDrop.getTag()); + if (item) + mInventory->removeItemAt(dragDrop.getTag()); + } return; } diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp index 722e1bbe9..8f0d49887 100644 --- a/src/gui/widgets/label.cpp +++ b/src/gui/widgets/label.cpp @@ -99,11 +99,8 @@ Label::Label(const Widget2 *const widget, mTextChanged(true) { const Font *const font = getFont(); - if (font) - { - setWidth(font->getWidth(caption)); - setHeight(font->getHeight()); - } + setWidth(font->getWidth(caption)); + setHeight(font->getHeight()); init(); } diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index 85e1a5b8f..6204102c4 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -122,10 +122,7 @@ ListBox::ListBox(const Widget2 *const widget, } const Font *const font = getFont(); - if (font) - mRowHeight = font->getHeight() + 2 * mItemPadding; - else - mRowHeight = 13; + mRowHeight = font->getHeight() + 2 * mItemPadding; } void ListBox::postInit() diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 1e43b31b5..df05ec3fa 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -1276,7 +1276,7 @@ void ScrollArea::setScrollbarWidth(const int width) void ScrollArea::showWidgetPart(Widget *const widget, const Rect &area) { const Widget *const content = getContent(); - if (widget != content) + if (widget != content || !content) return; BasicContainer::showWidgetPart(widget, area); diff --git a/src/gui/widgets/setupitem.h b/src/gui/widgets/setupitem.h index bc6443bb3..0853c6f19 100644 --- a/src/gui/widgets/setupitem.h +++ b/src/gui/widgets/setupitem.h @@ -71,7 +71,7 @@ class SetupItem notfinal : public ActionListener, Widget *getWidget() const A_WARN_UNUSED { return mWidget; } - Configuration *getConfig() const A_WARN_UNUSED; + Configuration *getConfig() const RETURNS_NONNULL A_WARN_UNUSED; virtual std::string getActionEventId() const A_WARN_UNUSED; diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index b6b0eceb4..33f07efe8 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -455,28 +455,25 @@ void TabbedArea::widgetResized(const Event &event A_UNUSED) - mWidgetContainer->getY() - widgetFrameSize; Widget *const w = getCurrentWidget(); - if (w) + ScrollArea *const scr = dynamic_cast<ScrollArea *const>(w); + if (scr) { - ScrollArea *const scr = dynamic_cast<ScrollArea *const>(w); - if (scr) + if (mFollowDownScroll && height != 0) { - if (mFollowDownScroll && height != 0) + const Rect &rect = w->getDimension(); + if (rect.height != 0 && rect.height > height + 2) { - const Rect &rect = w->getDimension(); - if (rect.height != 0 && rect.height > height + 2) + if (scr->getVerticalScrollAmount() + >= scr->getVerticalMaxScroll() - 2 + && scr->getVerticalScrollAmount() + <= scr->getVerticalMaxScroll() + 2) { - if (scr->getVerticalScrollAmount() - >= scr->getVerticalMaxScroll() - 2 - && scr->getVerticalScrollAmount() - <= scr->getVerticalMaxScroll() + 2) - { - const int newScroll = scr->getVerticalScrollAmount() - + rect.height - height; - w->setSize(mWidgetContainer->getWidth() - frameSize, - mWidgetContainer->getHeight() - frameSize); - if (newScroll) - scr->setVerticalScrollAmount(newScroll); - } + const int newScroll = scr->getVerticalScrollAmount() + + rect.height - height; + w->setSize(mWidgetContainer->getWidth() - frameSize, + mWidgetContainer->getHeight() - frameSize); + if (newScroll) + scr->setVerticalScrollAmount(newScroll); } } } diff --git a/src/gui/widgets/tabs/socialfriendstab.h b/src/gui/widgets/tabs/socialfriendstab.h index e09068d8d..5f9038f81 100644 --- a/src/gui/widgets/tabs/socialfriendstab.h +++ b/src/gui/widgets/tabs/socialfriendstab.h @@ -74,8 +74,6 @@ class SocialFriendsTab final : public SocialTab return; std::vector<Avatar*> *const avatars = mBeings->getMembers(); - if (!avatars) - return; std::vector<Avatar*>::iterator ia = avatars->begin(); while (ia != avatars->end()) diff --git a/src/gui/widgets/tabs/socialnavigationtab.h b/src/gui/widgets/tabs/socialnavigationtab.h index b649f2e2a..b4ad01128 100644 --- a/src/gui/widgets/tabs/socialnavigationtab.h +++ b/src/gui/widgets/tabs/socialnavigationtab.h @@ -170,7 +170,7 @@ class SocialNavigationTab final : public SocialTab return; std::vector<Avatar*> *const avatars = mBeings->getMembers(); - if (!avatars || avatars->size() <= static_cast<size_t>(num)) + if (avatars->size() <= static_cast<size_t>(num)) return; const Avatar *const ava = avatars->at(num); @@ -184,8 +184,6 @@ class SocialNavigationTab final : public SocialTab return; std::vector<Avatar*> *const avatars = mBeings->getMembers(); - if (!avatars) - return; const Map *const map = socialWindow->getMap(); if (!map) @@ -220,9 +218,6 @@ class SocialNavigationTab final : public SocialTab return -1; std::vector<Avatar*> *const avatars = mBeings->getMembers(); - if (!avatars) - return -1; - const Map *const map = socialWindow->getMap(); if (!map) return -1; @@ -255,10 +250,6 @@ class SocialNavigationTab final : public SocialTab return; std::vector<Avatar*> *const avatars = mBeings->getMembers(); - - if (!avatars) - return; - const MapItem *const portal = map->findPortalXY(x, y); if (!portal) return; @@ -288,10 +279,6 @@ class SocialNavigationTab final : public SocialTab return; std::vector<Avatar*> *const avatars = mBeings->getMembers(); - - if (!avatars) - return; - std::vector<Avatar*>::iterator i = avatars->begin(); const std::vector<Avatar*>::iterator i_end = avatars->end(); diff --git a/src/gui/widgets/tabs/socialplayerstab.h b/src/gui/widgets/tabs/socialplayerstab.h index a7634014b..c0310015f 100644 --- a/src/gui/widgets/tabs/socialplayerstab.h +++ b/src/gui/widgets/tabs/socialplayerstab.h @@ -119,9 +119,6 @@ class SocialPlayersTab final : public SocialTab Avatar* findAvatarbyName(const std::string &name) { std::vector<Avatar*> *const avatars = mBeings->getMembers(); - if (!avatars) - return nullptr; - Avatar *ava = nullptr; std::vector<Avatar*>::const_iterator i = avatars->begin(); const std::vector<Avatar*>::const_iterator i_end = avatars->end(); @@ -141,9 +138,6 @@ class SocialPlayersTab final : public SocialTab void getPlayersAvatars() { std::vector<Avatar*> *const avatars = mBeings->getMembers(); - if (!avatars) - return; - if (actorManager) { StringVect names; diff --git a/src/gui/widgets/tabstrip.cpp b/src/gui/widgets/tabstrip.cpp index d3f334e8a..025eb7ac7 100644 --- a/src/gui/widgets/tabstrip.cpp +++ b/src/gui/widgets/tabstrip.cpp @@ -63,6 +63,8 @@ void TabStrip::action(const ActionEvent &event) { Widget *const widget = event.getSource(); Button *const button = static_cast<Button*>(widget); + if (!button) + return; if (button->isPressed2()) { FOR_EACH (WidgetListConstIterator, iter, mWidgets) diff --git a/src/gui/widgets/widget.h b/src/gui/widgets/widget.h index c5573b404..840e7ce31 100644 --- a/src/gui/widgets/widget.h +++ b/src/gui/widgets/widget.h @@ -682,7 +682,7 @@ class Widget notfinal : public Widget2 * @see setFont, setGlobalFont * @since 0.1.0 */ - Font *getFont() const A_WARN_UNUSED; + Font *getFont() const RETURNS_NONNULL A_WARN_UNUSED; /** * Sets the global font to be used by default for all widgets. @@ -1027,7 +1027,7 @@ class Widget notfinal : public Widget2 void windowResized(); - static Widget *callPostInit(Widget *const widget); + static Widget *callPostInit(Widget *const widget) RETURNS_NONNULL; virtual void postInit() { } diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 2316af653..73355e3fc 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -641,11 +641,14 @@ void Window::widgetResized(const Event &event A_UNUSED) if (showClose) { const Image *const button = mSkin->getCloseImage(false); - const int buttonWidth = button->getWidth(); - mCloseRect.x = mDimension.width - buttonWidth - mClosePadding; - mCloseRect.y = mClosePadding; - mCloseRect.width = buttonWidth; - mCloseRect.height = button->getHeight(); + if (button) + { + const int buttonWidth = button->getWidth(); + mCloseRect.x = mDimension.width - buttonWidth - mClosePadding; + mCloseRect.y = mClosePadding; + mCloseRect.width = buttonWidth; + mCloseRect.height = button->getHeight(); + } } if (mStickyButton) { |