diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-10-11 14:48:19 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-10-11 15:24:57 +0300 |
commit | f1b82c1b06604c2c1eed750a6c980aa0b5355560 (patch) | |
tree | 3e524583691af0e5a17e5ee974439b4c6ea07ef4 /src/gui | |
parent | 452f2489bf3225235797ea08ea0d466f80409a87 (diff) | |
download | plus-f1b82c1b06604c2c1eed750a6c980aa0b5355560.tar.gz plus-f1b82c1b06604c2c1eed750a6c980aa0b5355560.tar.bz2 plus-f1b82c1b06604c2c1eed750a6c980aa0b5355560.tar.xz plus-f1b82c1b06604c2c1eed750a6c980aa0b5355560.zip |
First part of checks from Parasoft C++ Test.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/widgets/characterviewnormal.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/scrollarea.cpp | 18 | ||||
-rw-r--r-- | src/gui/widgets/skillmodel.cpp | 5 | ||||
-rw-r--r-- | src/gui/widgets/tabs/chattab.cpp | 3 | ||||
-rw-r--r-- | src/gui/widgets/tabs/setup_colors.cpp | 3 | ||||
-rw-r--r-- | src/gui/windows/chatwindow.cpp | 12 | ||||
-rw-r--r-- | src/gui/windows/debugwindow.cpp | 14 | ||||
-rw-r--r-- | src/gui/windows/statuswindow.cpp | 8 | ||||
-rw-r--r-- | src/gui/windows/whoisonline.cpp | 3 |
9 files changed, 41 insertions, 29 deletions
diff --git a/src/gui/widgets/characterviewnormal.cpp b/src/gui/widgets/characterviewnormal.cpp index 50dd8f7e4..7e6fe380d 100644 --- a/src/gui/widgets/characterviewnormal.cpp +++ b/src/gui/widgets/characterviewnormal.cpp @@ -45,9 +45,9 @@ CharacterViewNormal::CharacterViewNormal(CharSelectDialog *const widget, character->setVisible(true); } show(0); + const CharacterDisplay *const firtChar = (*mCharacterEntries)[0]; + setWidth(firtChar->getWidth() * 5 + mPadding * 2); } - const CharacterDisplay *const firtChar = (*mCharacterEntries)[0]; - setWidth(firtChar->getWidth() * 5 + mPadding * 2); setHeight(210 + config.getIntValue("fontSize") * 2); } diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index e40b1ce18..3d79a2a2e 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -639,8 +639,12 @@ void ScrollArea::widgetResized(const gcn::Event &event A_UNUSED) { mRedraw = true; const unsigned int frameSize = 2 * mFrameSize; - getContent()->setSize(mDimension.width - frameSize, - mDimension.height - frameSize); + gcn::Widget *const content = getContent(); + if (content) + { + content->setSize(mDimension.width - frameSize, + mDimension.height - frameSize); + } } void ScrollArea::widgetMoved(const gcn::Event& event A_UNUSED) @@ -915,15 +919,11 @@ gcn::Rectangle ScrollArea::getVerticalMarkerDimension() if (length > height) length = height; - if (getVerticalMaxScroll() != 0) - { - pos = ((height - length) * mVScroll) - / getVerticalMaxScroll(); - } + const int maxScroll = getVerticalMaxScroll(); + if (maxScroll != 0) + pos = ((height - length) * mVScroll) / maxScroll; else - { pos = 0; - } } return gcn::Rectangle(mDimension.width - mScrollbarWidth, h2 + pos, diff --git a/src/gui/widgets/skillmodel.cpp b/src/gui/widgets/skillmodel.cpp index c4d79e450..fab83cb46 100644 --- a/src/gui/widgets/skillmodel.cpp +++ b/src/gui/widgets/skillmodel.cpp @@ -43,8 +43,9 @@ SkillInfo *SkillModel::getSkillAt(const int i) const std::string SkillModel::getElementAt(int i) { - if (getSkillAt(i)) - return getSkillAt(i)->data->name; + const SkillInfo *const info = getSkillAt(i); + if (info) + return info->data->name; else return std::string(); } diff --git a/src/gui/widgets/tabs/chattab.cpp b/src/gui/widgets/tabs/chattab.cpp index b4a8cb158..2659ab7f9 100644 --- a/src/gui/widgets/tabs/chattab.cpp +++ b/src/gui/widgets/tabs/chattab.cpp @@ -331,6 +331,9 @@ void ChatTab::chatLog(std::string line, Own own, void ChatTab::chatLog(const std::string &nick, std::string msg) { + if (!player_node) + return; + const Own byWho = (nick == player_node->getName() ? BY_PLAYER : BY_OTHER); if (byWho == BY_OTHER && config.getBoolValue("removeColors")) msg = removeColors(msg); diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp index 13303bd88..c29da4a8a 100644 --- a/src/gui/widgets/tabs/setup_colors.cpp +++ b/src/gui/widgets/tabs/setup_colors.cpp @@ -279,7 +279,8 @@ void Setup_Colors::valueChanged(const gcn::SelectionEvent &event A_UNUSED) break; case UserPalette::ATTACK_RANGE_BORDER: case UserPalette::HOME_PLACE_BORDER: - mTextPreview->setFont(gui->getFont()); + if (gui) + mTextPreview->setFont(gui->getFont()); mTextPreview->setTextColor(col); mTextPreview->setOutline(false); mTextPreview->setShadow(false); diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index 353212025..9a7a348c8 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -1445,16 +1445,8 @@ void ChatWindow::resortChatLog(std::string line, Own own, } else if (mShowAllLang) { - if (langChatTab) - { - langChatTab->chatLog(prefix + line, own, - ignoreRecord, tryRemoveColors); - } - else if (localChatTab) - { - localChatTab->chatLog(prefix + line, own, - ignoreRecord, tryRemoveColors); - } + langChatTab->chatLog(prefix + line, own, + ignoreRecord, tryRemoveColors); } } else if (localChatTab && channel.empty()) diff --git a/src/gui/windows/debugwindow.cpp b/src/gui/windows/debugwindow.cpp index 90a8fccd6..24a77a402 100644 --- a/src/gui/windows/debugwindow.cpp +++ b/src/gui/windows/debugwindow.cpp @@ -531,9 +531,17 @@ NetDebugTab::NetDebugTab(const Widget2 *const widget) : void NetDebugTab::logic() { BLOCK_START("NetDebugTab::logic") - // TRANSLATORS: debug window label - mPingLabel->setCaption(strprintf(_("Ping: %s ms"), - player_node->getPingTime().c_str())); + if (player_node) + { + // TRANSLATORS: debug window label + mPingLabel->setCaption(strprintf(_("Ping: %s ms"), + player_node->getPingTime().c_str())); + } + else + { + // TRANSLATORS: debug window label + mPingLabel->setCaption(strprintf(_("Ping: %s ms"), "0")); + } // TRANSLATORS: debug window label mInPackets1Label->setCaption(strprintf(_("In: %d bytes/s"), PacketCounters::getInBytes())); diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp index bbc4558b0..87dc94e8e 100644 --- a/src/gui/windows/statuswindow.cpp +++ b/src/gui/windows/statuswindow.cpp @@ -598,8 +598,12 @@ void StatusWindow::updateWeightBar(ProgressBar *const bar) const int totalWeight = PlayerInfo::getAttribute( PlayerInfo::TOTAL_WEIGHT); const int maxWeight = PlayerInfo::getAttribute(PlayerInfo::MAX_WEIGHT); - const float progress = static_cast<float>(totalWeight) - / static_cast<float>(maxWeight); + float progress = 1.0F; + if (maxWeight) + { + progress = static_cast<float>(totalWeight) + / static_cast<float>(maxWeight); + } bar->setText(strprintf("%s/%s", Units::formatWeight( totalWeight).c_str(), Units::formatWeight(maxWeight).c_str())); bar->setProgress(progress); diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp index e7c60bb39..68979a682 100644 --- a/src/gui/windows/whoisonline.cpp +++ b/src/gui/windows/whoisonline.cpp @@ -329,6 +329,9 @@ void WhoIsOnline::loadWebList() // Reallocate and include terminating 0 character mMemoryBuffer = static_cast<char*>( realloc(mMemoryBuffer, mDownloadedBytes + 1)); + if (!mMemoryBuffer) + return; + mMemoryBuffer[mDownloadedBytes] = '\0'; mBrowserBox->clearRows(); |