summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2010-07-16 23:34:17 +0300
committerJared Adams <jaxad0127@gmail.com>2010-07-16 15:45:32 -0600
commit04e4f0da4b6242f39d09794edad394587ddea620 (patch)
tree773e528d78763410242c790b2782e728bd127fa0 /src
parentabde0f51b3062c158fb52e9dfff23d21d3be03d1 (diff)
downloadmana-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')
-rw-r--r--src/gui/chat.cpp25
-rw-r--r--src/gui/chat.h2
-rw-r--r--src/gui/widgets/whispertab.cpp3
3 files changed, 24 insertions, 6 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();
diff --git a/src/gui/chat.h b/src/gui/chat.h
index 3de2b146..e49d02c9 100644
--- a/src/gui/chat.h
+++ b/src/gui/chat.h
@@ -186,6 +186,8 @@ class ChatWindow : public Window,
void removeWhisper(const std::string &nick);
+ void removeAllWhispers();
+
void autoComplete();
std::string autoCompleteHistory(std::string partName);
diff --git a/src/gui/widgets/whispertab.cpp b/src/gui/widgets/whispertab.cpp
index 858a2e6b..7542e251 100644
--- a/src/gui/widgets/whispertab.cpp
+++ b/src/gui/widgets/whispertab.cpp
@@ -41,7 +41,8 @@ WhisperTab::WhisperTab(const std::string &nick) :
WhisperTab::~WhisperTab()
{
- chatWindow->removeWhisper(mNick);
+ if (chatWindow)
+ chatWindow->removeWhisper(mNick);
}
void WhisperTab::handleInput(const std::string &msg)