diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-02-02 05:11:50 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-02-02 05:11:50 +0300 |
commit | f498d80c587033bffb9abedb2b0827ad8d4a2a32 (patch) | |
tree | 82da8928768b2159c199c2d033388a071f228582 /src/gui | |
parent | 1ba44aeb62414ea349e462b6d4fccbaac00be115 (diff) | |
download | mv-f498d80c587033bffb9abedb2b0827ad8d4a2a32.tar.gz mv-f498d80c587033bffb9abedb2b0827ad8d4a2a32.tar.bz2 mv-f498d80c587033bffb9abedb2b0827ad8d4a2a32.tar.xz mv-f498d80c587033bffb9abedb2b0827ad8d4a2a32.zip |
Add some checks after automatic checking.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/charselectdialog.cpp | 2 | ||||
-rw-r--r-- | src/gui/chatwindow.cpp | 3 | ||||
-rw-r--r-- | src/gui/serverdialog.cpp | 2 | ||||
-rw-r--r-- | src/gui/setup.cpp | 2 | ||||
-rw-r--r-- | src/gui/setup_relations.cpp | 7 | ||||
-rw-r--r-- | src/gui/setup_video.cpp | 4 | ||||
-rw-r--r-- | src/gui/whoisonline.cpp | 3 | ||||
-rw-r--r-- | src/gui/widgets/chattab.cpp | 14 | ||||
-rw-r--r-- | src/gui/widgets/textbox.h | 3 |
9 files changed, 27 insertions, 13 deletions
diff --git a/src/gui/charselectdialog.cpp b/src/gui/charselectdialog.cpp index 638691bab..d2b74a632 100644 --- a/src/gui/charselectdialog.cpp +++ b/src/gui/charselectdialog.cpp @@ -386,7 +386,7 @@ bool CharSelectDialog::selectByName(const std::string &name, Net::Character *character = mCharacterEntries[i]->getCharacter(); if (mCharacterEntries[i] && character) { - if (character->dummy->getName() == name) + if ( character->dummy && character->dummy->getName() == name) { if (mCharacterEntries[i]) mCharacterEntries[i]->requestFocus(); diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 3d52e28f4..6831ad5b6 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -548,6 +548,9 @@ void ChatWindow::removeTab(ChatTab *tab) void ChatWindow::addTab(ChatTab *tab) { + if (!tab) + return; + mChatTabs->addTab(tab, tab->mScrollArea); // Update UI diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index bdde4b96f..98d9bbfee 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -680,7 +680,7 @@ void ServerDialog::saveCustomServers(const ServerInfo ¤tServer, int ServerDialog::downloadUpdate(void *ptr, DownloadStatus status, size_t total, size_t remaining) { - if (status == DOWNLOAD_STATUS_CANCELLED) + if (!ptr || status == DOWNLOAD_STATUS_CANCELLED) return -1; ServerDialog *sd = reinterpret_cast<ServerDialog*>(ptr); diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index bac474950..3408fba33 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -75,7 +75,7 @@ Setup::Setup(): nullptr }; int x = width; - for (const char **curBtn = buttonNames; *curBtn; ++curBtn) + for (const char **curBtn = buttonNames; *curBtn; ++ curBtn) { Button *btn = new Button(gettext(*curBtn), *curBtn, this); x -= btn->getWidth() + 5; diff --git a/src/gui/setup_relations.cpp b/src/gui/setup_relations.cpp index 9ddef9e1a..571856a14 100644 --- a/src/gui/setup_relations.cpp +++ b/src/gui/setup_relations.cpp @@ -193,6 +193,8 @@ public: std::string getPlayerAt(int index) const { + if (index < 0 || index >= (signed)mPlayers->size()) + return ""; return (*mPlayers)[index]; } @@ -257,10 +259,7 @@ Setup_Relations::Setup_Relations(): mIgnoreActionChoicesBox = new DropDown(mIgnoreActionChoicesModel); for (int i = 0; i < COLUMNS_NR; i++) - { - mPlayerTableTitleModel->set(0, i, - new Label(gettext(table_titles[i]))); - } + mPlayerTableTitleModel->set(0, i, new Label(gettext(table_titles[i]))); mPlayerTitleTable->setLinewiseSelection(true); diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index d0a6ac257..48d489513 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -143,11 +143,11 @@ ModeListModel::ModeListModel() } else { - for (int i = 0; modes[i]; ++i) + for (int i = 0; modes[i]; ++ i) { const std::string modeString = toString(static_cast<int>(modes[i]->w)) + "x" - + toString(static_cast<int>(modes[i]->h)); + + toString(static_cast<int>(modes[i]->h)); mVideoModes.push_back(modeString); } } diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index 7965221e4..205a1aae1 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -464,6 +464,9 @@ void WhoIsOnline::loadWebList() size_t WhoIsOnline::memoryWrite(void *ptr, size_t size, size_t nmemb, FILE *stream) { + if (!stream) + return 0; + WhoIsOnline *wio = reinterpret_cast<WhoIsOnline *>(stream); size_t totalMem = size * nmemb; wio->mMemoryBuffer = static_cast<char*>(realloc(wio->mMemoryBuffer, diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index aea367482..6d5dfc9dd 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -224,9 +224,17 @@ void ChatTab::chatLog(std::string line, Own own, { struct tm *timeInfo; timeInfo = localtime(&t); - line = strprintf("%s[%02d:%02d] %s%s", lineColor.c_str(), - timeInfo->tm_hour, timeInfo->tm_min, tmp.nick.c_str(), - tmp.text.c_str()); + if (timeInfo) + { + line = strprintf("%s[%02d:%02d] %s%s", lineColor.c_str(), + timeInfo->tm_hour, timeInfo->tm_min, tmp.nick.c_str(), + tmp.text.c_str()); + } + else + { + line = strprintf("%s %s%s", lineColor.c_str(), + tmp.nick.c_str(), tmp.text.c_str()); + } } else { diff --git a/src/gui/widgets/textbox.h b/src/gui/widgets/textbox.h index 6d2467b38..a052247c4 100644 --- a/src/gui/widgets/textbox.h +++ b/src/gui/widgets/textbox.h @@ -59,7 +59,8 @@ class TextBox : public gcn::TextBox */ inline void draw(gcn::Graphics *graphics) { - setForegroundColor(*mTextColor); + if (mTextColor) + setForegroundColor(*mTextColor); gcn::TextBox::draw(graphics); } |