diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-04-29 14:01:37 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-04-29 14:10:28 +0300 |
commit | f820365eed7e956e67e6122a8a5ab529e7df9474 (patch) | |
tree | 9ee43bae2f7cafa38ab0cf018b8dbaf49d531f38 /src/gui/windows/mailwindow.cpp | |
parent | 4b0f30b1e1879cee6d65394d826bba21eca6c40b (diff) | |
download | manaplus-f820365eed7e956e67e6122a8a5ab529e7df9474.tar.gz manaplus-f820365eed7e956e67e6122a8a5ab529e7df9474.tar.bz2 manaplus-f820365eed7e956e67e6122a8a5ab529e7df9474.tar.xz manaplus-f820365eed7e956e67e6122a8a5ab529e7df9474.zip |
Fix time in mail view window.
Also fix possible leaks in mail windows.
Diffstat (limited to 'src/gui/windows/mailwindow.cpp')
-rw-r--r-- | src/gui/windows/mailwindow.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/gui/windows/mailwindow.cpp b/src/gui/windows/mailwindow.cpp index ef6444405..1d0bbca62 100644 --- a/src/gui/windows/mailwindow.cpp +++ b/src/gui/windows/mailwindow.cpp @@ -51,6 +51,7 @@ MailWindow::MailWindow() : Window(_("Mail"), false, nullptr, "mail.xml"), ActionListener(), mMessages(), + mMessagesMap(), mMailModel(new ExtendedNamesModel), mListBox(new ExtendedListBox(this, mMailModel, "extendedlistbox.xml")), // TRANSLATORS: mail window button @@ -98,6 +99,8 @@ MailWindow::~MailWindow() { delete_all(mMessages); delete2(mMailModel); + delete2(mailViewWindow); + delete2(mailEditWindow); } void MailWindow::action(const ActionEvent &event) @@ -126,19 +129,34 @@ void MailWindow::clear() { delete_all(mMessages); mMessages.clear(); + mMessagesMap.clear(); mMailModel->clear(); mListBox->setSelected(-1); } void MailWindow::addMail(MailMessage *const message) { + if (!message) + return; mMessages.push_back(message); mMailModel->add(strprintf("%s %s", message->unread ? " " : "U", message->title.c_str())); + mMessagesMap[message->id] = message; } -void MailWindow::showMessage(const MailMessage *const mail) +void MailWindow::showMessage(MailMessage *const mail) { - new MailView(mail); + if (!mail) + return; + const std::map<int, MailMessage*>::const_iterator + it = mMessagesMap.find(mail->id); + if (it != mMessagesMap.end()) + { + const MailMessage *const mail2 = (*it).second; + mail->time = mail2->time; + mail->strTime = mail2->strTime; + } + delete mailViewWindow; + mailViewWindow = new MailView(mail); } |