From f820365eed7e956e67e6122a8a5ab529e7df9474 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 29 Apr 2015 14:01:37 +0300 Subject: Fix time in mail view window. Also fix possible leaks in mail windows. --- src/gui/windows/mailwindow.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/gui/windows/mailwindow.cpp') 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::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); } -- cgit v1.2.3-70-g09d2