diff options
author | Andrei Karas <akaras@inbox.ru> | 2010-07-16 23:34:17 +0300 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2010-07-16 15:45:32 -0600 |
commit | 04e4f0da4b6242f39d09794edad394587ddea620 (patch) | |
tree | 773e528d78763410242c790b2782e728bd127fa0 /src/gui/chat.cpp | |
parent | abde0f51b3062c158fb52e9dfff23d21d3be03d1 (diff) | |
download | mana-04e4f0da4b6242f39d09794edad394587ddea620.tar.gz mana-04e4f0da4b6242f39d09794edad394587ddea620.tar.bz2 mana-04e4f0da4b6242f39d09794edad394587ddea620.tar.xz mana-04e4f0da4b6242f39d09794edad394587ddea620.zip |
Fix memory corruption in chat on exit.
Signed-off-by: Jared Adams <jaxad0127@gmail.com>
Diffstat (limited to 'src/gui/chat.cpp')
-rw-r--r-- | src/gui/chat.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index d53bcf0a..f87a8a3d 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -117,7 +117,7 @@ ChatWindow::~ChatWindow() { config.setValue("ReturnToggles", mReturnToggles); delete mRecorder; - delete_all(mWhispers); + removeAllWhispers(); delete mItemLinkHandler; } @@ -233,10 +233,6 @@ bool ChatWindow::isInputFocused() const void ChatWindow::removeTab(ChatTab *tab) { - // Prevent removal of the local chat tab - if (tab == localChatTab) - return; - mChatTabs->removeTab(tab); } @@ -258,6 +254,25 @@ void ChatWindow::removeWhisper(const std::string &nick) mWhispers.erase(tempNick); } +void ChatWindow::removeAllWhispers() +{ + TabMap::iterator iter; + std::list<ChatTab*> tabs; + + for (iter = mWhispers.begin(); iter != mWhispers.end(); ++iter) + { + tabs.push_back(iter->second); + } + + for (std::list<ChatTab*>::iterator it = tabs.begin(); + it != tabs.end(); ++it) + { + delete *it; + } + + mWhispers.clear(); +} + void ChatWindow::chatInput(const std::string &msg) { ChatTab *tab = getFocused(); |