diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-05-24 21:28:14 +0200 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-05-24 21:37:34 +0200 |
commit | c354af888779c9038cedf64c1502574eb8b29399 (patch) | |
tree | 62423b30337228fd4f92f0b4c2c26d77eaeab19a /src/gui/chat.cpp | |
parent | 9ece3811d6ca6577b238a08eea50449d89e9eba1 (diff) | |
download | mana-c354af888779c9038cedf64c1502574eb8b29399.tar.gz mana-c354af888779c9038cedf64c1502574eb8b29399.tar.bz2 mana-c354af888779c9038cedf64c1502574eb8b29399.tar.xz mana-c354af888779c9038cedf64c1502574eb8b29399.zip |
Fixed crash on whispering somebody a second time after closing the tab
The tabs are referred to case-insentively, but the removal of references
to deleted tabs was happening case-sensitively. This caused roaming
pointers to stay around and get reused later, crashing the client.
Diffstat (limited to 'src/gui/chat.cpp')
-rw-r--r-- | src/gui/chat.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 414d1e02..73af83ff 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -292,7 +292,9 @@ void ChatWindow::addTab(ChatTab *tab) void ChatWindow::removeWhisper(const std::string &nick) { - mWhispers.erase(nick); + std::string tempNick = nick; + toLower(tempNick); + mWhispers.erase(tempNick); } void ChatWindow::chatInput(std::string &msg) @@ -444,12 +446,13 @@ void ChatWindow::whisper(const std::string &nick, std::string mes, bool own) if (tempNick.compare(playerName) == 0) return; - ChatTab *tab = mWhispers[tempNick]; + ChatTab *tab = 0; + TabMap::const_iterator i = mWhispers.find(tempNick); - if (!tab && config.getValue("whispertab", false)) - { + if (i != mWhispers.end()) + tab = i->second; + else if (config.getValue("whispertab", false)) tab = addWhisperTab(nick); - } if (tab) { @@ -480,10 +483,12 @@ ChatTab *ChatWindow::addWhisperTab(const std::string &nick, bool switchTo) toLower(playerName); toLower(tempNick); - if (mWhispers[tempNick] || tempNick.compare(playerName) == 0) + if (mWhispers.find(tempNick) != mWhispers.end() + || tempNick.compare(playerName) == 0) return NULL; - ChatTab *ret = mWhispers[tempNick] = new WhisperTab(nick); + ChatTab *ret = new WhisperTab(nick); + mWhispers[tempNick] = ret; if (switchTo) mChatTabs->setSelectedTab(ret); |