author | leseb <leseb> | 2002-06-16 16:15:47 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-06-16 16:15:47 (UTC) |
commit | ea69cfbbde29fef2f792d1eab702699aada088bf (patch) (unidiff) | |
tree | 1b908b905a16deaba7331d2f0b0c844f94235da0 | |
parent | d4414131cdf32677e8d54a18827f2e772718c3f7 (diff) | |
download | opie-ea69cfbbde29fef2f792d1eab702699aada088bf.zip opie-ea69cfbbde29fef2f792d1eab702699aada088bf.tar.gz opie-ea69cfbbde29fef2f792d1eab702699aada088bf.tar.bz2 |
Fix memory leaks
-rw-r--r-- | noncore/unsupported/mail2/composer.cpp | 28 | ||||
-rw-r--r-- | noncore/unsupported/mail2/composer.h | 5 | ||||
-rw-r--r-- | noncore/unsupported/mail2/mainwindow.cpp | 26 | ||||
-rw-r--r-- | noncore/unsupported/mail2/searchdiag.cpp | 6 | ||||
-rw-r--r-- | noncore/unsupported/mail2/viewmail.cpp | 44 | ||||
-rw-r--r-- | noncore/unsupported/mail2/viewmail.h | 5 |
6 files changed, 88 insertions, 26 deletions
diff --git a/noncore/unsupported/mail2/composer.cpp b/noncore/unsupported/mail2/composer.cpp index 82ed117..7f65dba 100644 --- a/noncore/unsupported/mail2/composer.cpp +++ b/noncore/unsupported/mail2/composer.cpp | |||
@@ -3,12 +3,13 @@ | |||
3 | #include <qpopupmenu.h> | 3 | #include <qpopupmenu.h> |
4 | #include <qcombobox.h> | 4 | #include <qcombobox.h> |
5 | #include <qlineedit.h> | 5 | #include <qlineedit.h> |
6 | #include <qaction.h> | 6 | #include <qaction.h> |
7 | #include <qtimer.h> | 7 | #include <qtimer.h> |
8 | #include <qlabel.h> | 8 | #include <qlabel.h> |
9 | #include <qapplication.h> | ||
9 | 10 | ||
10 | #include <qpe/resource.h> | 11 | #include <qpe/resource.h> |
11 | 12 | ||
12 | #include "addresspicker.h" | 13 | #include "addresspicker.h" |
13 | #include "listviewplus.h" | 14 | #include "listviewplus.h" |
14 | #include "smtphandler.h" | 15 | #include "smtphandler.h" |
@@ -22,13 +23,13 @@ AttachViewItem::AttachViewItem(QListView *parent, Attachment &attachment) | |||
22 | setPixmap(0, _attachment.docLnk()->pixmap().isNull() ? Resource::loadPixmap("UnknownDocument-14") : _attachment.docLnk()->pixmap()); | 23 | setPixmap(0, _attachment.docLnk()->pixmap().isNull() ? Resource::loadPixmap("UnknownDocument-14") : _attachment.docLnk()->pixmap()); |
23 | setText(0, _attachment.newName().isEmpty() ? _attachment.fileName() : _attachment.newName()); | 24 | setText(0, _attachment.newName().isEmpty() ? _attachment.fileName() : _attachment.newName()); |
24 | setText(1, _attachment.description()); | 25 | setText(1, _attachment.description()); |
25 | } | 26 | } |
26 | 27 | ||
27 | Composer::Composer(QWidget *parent, const char *name, WFlags fl) | 28 | Composer::Composer(QWidget *parent, const char *name, WFlags fl) |
28 | : ComposerBase(parent, name, fl) | 29 | : ComposerBase(parent, name, fl), _inLoop(false) |
29 | { | 30 | { |
30 | abort->setEnabled(false); | 31 | abort->setEnabled(false); |
31 | to->setFocus(); | 32 | to->setFocus(); |
32 | 33 | ||
33 | connect(sendmail, SIGNAL(activated()), SLOT(slotSendMail())); | 34 | connect(sendmail, SIGNAL(activated()), SLOT(slotSendMail())); |
34 | connect(addressbook, SIGNAL(activated()), SLOT(slotOpenAddressPicker())); | 35 | connect(addressbook, SIGNAL(activated()), SLOT(slotOpenAddressPicker())); |
@@ -40,12 +41,37 @@ Composer::Composer(QWidget *parent, const char *name, WFlags fl) | |||
40 | connect(attachPopup, SIGNAL(activated(int)), SLOT(slotPopupHandler(int))); | 41 | connect(attachPopup, SIGNAL(activated(int)), SLOT(slotPopupHandler(int))); |
41 | 42 | ||
42 | QTimer::singleShot(0, this, SLOT(slotFillStuff())); | 43 | QTimer::singleShot(0, this, SLOT(slotFillStuff())); |
43 | QTimer::singleShot(0, this, SLOT(slotResizing())); | 44 | QTimer::singleShot(0, this, SLOT(slotResizing())); |
44 | } | 45 | } |
45 | 46 | ||
47 | Composer::~Composer() | ||
48 | { | ||
49 | hide(); | ||
50 | } | ||
51 | |||
52 | void Composer::hide() | ||
53 | { | ||
54 | QWidget::hide(); | ||
55 | |||
56 | if (_inLoop) { | ||
57 | _inLoop = false; | ||
58 | qApp->exit_loop(); | ||
59 | } | ||
60 | } | ||
61 | |||
62 | void Composer::exec() | ||
63 | { | ||
64 | show(); | ||
65 | |||
66 | if (!_inLoop) { | ||
67 | _inLoop = true; | ||
68 | qApp->enter_loop(); | ||
69 | } | ||
70 | } | ||
71 | |||
46 | void Composer::setSendMail(SendMail &sendMail) | 72 | void Composer::setSendMail(SendMail &sendMail) |
47 | { | 73 | { |
48 | to->setText(sendMail.to()); | 74 | to->setText(sendMail.to()); |
49 | cc->setText(sendMail.cc()); | 75 | cc->setText(sendMail.cc()); |
50 | bcc->setText(sendMail.bcc()); | 76 | bcc->setText(sendMail.bcc()); |
51 | subject->setText(sendMail.subject()); | 77 | subject->setText(sendMail.subject()); |
diff --git a/noncore/unsupported/mail2/composer.h b/noncore/unsupported/mail2/composer.h index a1af121..2640d7e 100644 --- a/noncore/unsupported/mail2/composer.h +++ b/noncore/unsupported/mail2/composer.h | |||
@@ -23,12 +23,16 @@ private: | |||
23 | class Composer : public ComposerBase | 23 | class Composer : public ComposerBase |
24 | { | 24 | { |
25 | Q_OBJECT | 25 | Q_OBJECT |
26 | 26 | ||
27 | public: | 27 | public: |
28 | Composer(QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal); | 28 | Composer(QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal); |
29 | ~Composer(); | ||
30 | |||
31 | void hide(); | ||
32 | void exec(); | ||
29 | 33 | ||
30 | void setSendMail(SendMail &sendMail); | 34 | void setSendMail(SendMail &sendMail); |
31 | 35 | ||
32 | protected slots: | 36 | protected slots: |
33 | void slotPopupHandler(int itemid); | 37 | void slotPopupHandler(int itemid); |
34 | void slotSendMail(); | 38 | void slotSendMail(); |
@@ -42,11 +46,12 @@ protected slots: | |||
42 | void slotDelAttach(); | 46 | void slotDelAttach(); |
43 | 47 | ||
44 | protected: | 48 | protected: |
45 | QValueList<Account> accountsLoaded; | 49 | QValueList<Account> accountsLoaded; |
46 | 50 | ||
47 | private: | 51 | private: |
52 | bool _inLoop; | ||
48 | QString _inReplyTo; | 53 | QString _inReplyTo; |
49 | 54 | ||
50 | }; | 55 | }; |
51 | 56 | ||
52 | #endif | 57 | #endif |
diff --git a/noncore/unsupported/mail2/mainwindow.cpp b/noncore/unsupported/mail2/mainwindow.cpp index 4d15e23..2230dc0 100644 --- a/noncore/unsupported/mail2/mainwindow.cpp +++ b/noncore/unsupported/mail2/mainwindow.cpp | |||
@@ -33,33 +33,33 @@ MainWindow::MainWindow(QWidget *parent, const char *name, WFlags fl) | |||
33 | connect(findmails, SIGNAL(activated()), SLOT(slotSearch())); | 33 | connect(findmails, SIGNAL(activated()), SLOT(slotSearch())); |
34 | connect(configure, SIGNAL(activated()), SLOT(slotConfigure())); | 34 | connect(configure, SIGNAL(activated()), SLOT(slotConfigure())); |
35 | } | 35 | } |
36 | 36 | ||
37 | void MainWindow::slotCompose() | 37 | void MainWindow::slotCompose() |
38 | { | 38 | { |
39 | Composer *composer = new Composer(); | 39 | Composer composer(this, 0, true); |
40 | composer->showMaximized(); | 40 | composer.showMaximized(); |
41 | composer->show(); | 41 | composer.exec(); |
42 | } | 42 | } |
43 | 43 | ||
44 | void MainWindow::slotSearch() | 44 | void MainWindow::slotSearch() |
45 | { | 45 | { |
46 | SearchDiag *searchDiag = new SearchDiag(this, 0, true); | 46 | SearchDiag searchDiag(this, 0, true); |
47 | searchDiag->showMaximized(); | 47 | searchDiag.showMaximized(); |
48 | searchDiag->show(); | 48 | searchDiag.exec(); |
49 | } | 49 | } |
50 | 50 | ||
51 | void MainWindow::slotConfigure() | 51 | void MainWindow::slotConfigure() |
52 | { | 52 | { |
53 | ConfigDiag *configDiag = new ConfigDiag(this, 0, true); | 53 | ConfigDiag configDiag(this, 0, true); |
54 | configDiag->showMaximized(); | 54 | configDiag.showMaximized(); |
55 | configDiag->show(); | 55 | configDiag.exec(); |
56 | 56 | ||
57 | connect(configDiag, SIGNAL(changed()), folderView, SLOT(update())); | 57 | connect(&configDiag, SIGNAL(changed()), folderView, SLOT(update())); |
58 | } | 58 | } |
59 | 59 | ||
60 | void MainWindow::mailClicked(IMAPResponseFETCH mail, IMAPHandler *handler) | 60 | void MainWindow::mailClicked(IMAPResponseFETCH mail, IMAPHandler *handler) |
61 | { | 61 | { |
62 | ViewMail *viewMail = new ViewMail(mail, handler); | 62 | ViewMail viewMail(mail, handler, this, 0, true); |
63 | viewMail->showMaximized(); | 63 | viewMail.showMaximized(); |
64 | viewMail->show(); | 64 | viewMail.exec(); |
65 | } | 65 | } |
diff --git a/noncore/unsupported/mail2/searchdiag.cpp b/noncore/unsupported/mail2/searchdiag.cpp index 33b8afb..907f6ff 100644 --- a/noncore/unsupported/mail2/searchdiag.cpp +++ b/noncore/unsupported/mail2/searchdiag.cpp | |||
@@ -109,15 +109,15 @@ void SearchDiag::slotIMAPFetch(IMAPResponse &response) | |||
109 | QMessageBox::warning(this, tr("Error"), tr("<p>Couldn't fetch the mail headers. (Server said: %1)").arg(response.statusResponse().comment())); | 109 | QMessageBox::warning(this, tr("Error"), tr("<p>Couldn't fetch the mail headers. (Server said: %1)").arg(response.statusResponse().comment())); |
110 | } | 110 | } |
111 | } | 111 | } |
112 | 112 | ||
113 | void SearchDiag::slotMailClicked(IMAPResponseFETCH fetch, IMAPHandler *) | 113 | void SearchDiag::slotMailClicked(IMAPResponseFETCH fetch, IMAPHandler *) |
114 | { | 114 | { |
115 | ViewMail *viewMail = new ViewMail(fetch, _folder.topFolder().handler()); | 115 | ViewMail viewMail(fetch, _folder.topFolder().handler(), this, 0, true); |
116 | viewMail->showMaximized(); | 116 | viewMail.showMaximized(); |
117 | viewMail->show(); | 117 | viewMail.exec(); |
118 | } | 118 | } |
119 | 119 | ||
120 | void SearchDiag::slotInItemActivated(int index) | 120 | void SearchDiag::slotInItemActivated(int index) |
121 | { | 121 | { |
122 | if (index == INMENU_HEADERF) { | 122 | if (index == INMENU_HEADERF) { |
123 | other->setEnabled(true); | 123 | other->setEnabled(true); |
diff --git a/noncore/unsupported/mail2/viewmail.cpp b/noncore/unsupported/mail2/viewmail.cpp index ae1f5f3..3c88d99 100644 --- a/noncore/unsupported/mail2/viewmail.cpp +++ b/noncore/unsupported/mail2/viewmail.cpp | |||
@@ -1,9 +1,10 @@ | |||
1 | #include <qtextbrowser.h> | 1 | #include <qtextbrowser.h> |
2 | #include <qmessagebox.h> | 2 | #include <qmessagebox.h> |
3 | #include <qaction.h> | 3 | #include <qaction.h> |
4 | #include <qapplication.h> | ||
4 | 5 | ||
5 | #include "mailfactory.h" | 6 | #include "mailfactory.h" |
6 | #include "composer.h" | 7 | #include "composer.h" |
7 | #include "viewmail.h" | 8 | #include "viewmail.h" |
8 | 9 | ||
9 | AttachItem::AttachItem(QListView *parent, AttachItemStore &attachItemStore) | 10 | AttachItem::AttachItem(QListView *parent, AttachItemStore &attachItemStore) |
@@ -20,13 +21,13 @@ AttachItem::AttachItem(QListViewItem *parent, AttachItemStore &attachItemStore) | |||
20 | setText(0, _attachItemStore.mimeType()); | 21 | setText(0, _attachItemStore.mimeType()); |
21 | setText(1, _attachItemStore.fileName()); | 22 | setText(1, _attachItemStore.fileName()); |
22 | setText(2, _attachItemStore.description()); | 23 | setText(2, _attachItemStore.description()); |
23 | } | 24 | } |
24 | 25 | ||
25 | ViewMail::ViewMail(IMAPResponseFETCH &mail, IMAPHandler *handler, QWidget *parent, const char *name, WFlags fl) | 26 | ViewMail::ViewMail(IMAPResponseFETCH &mail, IMAPHandler *handler, QWidget *parent, const char *name, WFlags fl) |
26 | : ViewMailBase(parent, name, fl), _mail(mail), _handler(handler) | 27 | : ViewMailBase(parent, name, fl), _inLoop(false), _mail(mail), _handler(handler) |
27 | { | 28 | { |
28 | setCaption(caption().arg(mail.envelope().from()[0].name())); | 29 | setCaption(caption().arg(mail.envelope().from()[0].name())); |
29 | 30 | ||
30 | _gotBody = false; | 31 | _gotBody = false; |
31 | _mailHtml = tr( | 32 | _mailHtml = tr( |
32 | "<html><body>" | 33 | "<html><body>" |
@@ -58,12 +59,37 @@ ViewMail::ViewMail(IMAPResponseFETCH &mail, IMAPHandler *handler, QWidget *paren | |||
58 | browser->setText(QString(_mailHtml).arg(tr("Getting mail body from server. Please wait..."))); | 59 | browser->setText(QString(_mailHtml).arg(tr("Getting mail body from server. Please wait..."))); |
59 | 60 | ||
60 | _handler->iUid("FETCH", QString("%1 (BODY[1])").arg(mail.uid())); | 61 | _handler->iUid("FETCH", QString("%1 (BODY[1])").arg(mail.uid())); |
61 | connect(_handler, SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPUid(IMAPResponse &))); | 62 | connect(_handler, SIGNAL(gotResponse(IMAPResponse &)), SLOT(slotIMAPUid(IMAPResponse &))); |
62 | } | 63 | } |
63 | 64 | ||
65 | ViewMail::~ViewMail() | ||
66 | { | ||
67 | hide(); | ||
68 | } | ||
69 | |||
70 | void ViewMail::hide() | ||
71 | { | ||
72 | QWidget::hide(); | ||
73 | |||
74 | if (_inLoop) { | ||
75 | _inLoop = false; | ||
76 | qApp->exit_loop(); | ||
77 | } | ||
78 | } | ||
79 | |||
80 | void ViewMail::exec() | ||
81 | { | ||
82 | show(); | ||
83 | |||
84 | if (!_inLoop) { | ||
85 | _inLoop = true; | ||
86 | qApp->enter_loop(); | ||
87 | } | ||
88 | } | ||
89 | |||
64 | QString ViewMail::deHtml(const QString &string) | 90 | QString ViewMail::deHtml(const QString &string) |
65 | { | 91 | { |
66 | QString string_ = string; | 92 | QString string_ = string; |
67 | string_.replace(QRegExp("&"), "&"); | 93 | string_.replace(QRegExp("&"), "&"); |
68 | string_.replace(QRegExp("<"), "<"); | 94 | string_.replace(QRegExp("<"), "<"); |
69 | string_.replace(QRegExp(">"), ">"); | 95 | string_.replace(QRegExp(">"), ">"); |
@@ -98,16 +124,16 @@ void ViewMail::slotReply() | |||
98 | SendMail sendMail; | 124 | SendMail sendMail; |
99 | sendMail.setTo(_mail.envelope().from()[0].toString()); | 125 | sendMail.setTo(_mail.envelope().from()[0].toString()); |
100 | sendMail.setSubject(prefix + _mail.envelope().subject()); | 126 | sendMail.setSubject(prefix + _mail.envelope().subject()); |
101 | sendMail.setInReplyTo(_mail.envelope().messageId()); | 127 | sendMail.setInReplyTo(_mail.envelope().messageId()); |
102 | sendMail.setMessage(rtext); | 128 | sendMail.setMessage(rtext); |
103 | 129 | ||
104 | Composer *composer = new Composer(0, 0, Qt::WType_Modal); | 130 | Composer composer(this, 0, true); |
105 | composer->setSendMail(sendMail); | 131 | composer.setSendMail(sendMail); |
106 | composer->showMaximized(); | 132 | composer.showMaximized(); |
107 | composer->show(); | 133 | composer.exec(); |
108 | } | 134 | } |
109 | 135 | ||
110 | void ViewMail::slotForward() | 136 | void ViewMail::slotForward() |
111 | { | 137 | { |
112 | if (!_gotBody) { | 138 | if (!_gotBody) { |
113 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); | 139 | QMessageBox::information(this, tr("Error"), tr("<p>The mail body is not yet downloaded, so you cannot forward yet."), tr("Ok")); |
@@ -142,16 +168,16 @@ void ViewMail::slotForward() | |||
142 | ftext += QString("----- End forwarded message -----\n"); | 168 | ftext += QString("----- End forwarded message -----\n"); |
143 | 169 | ||
144 | SendMail sendMail; | 170 | SendMail sendMail; |
145 | sendMail.setSubject("Fwd: " + _mail.envelope().subject()); | 171 | sendMail.setSubject("Fwd: " + _mail.envelope().subject()); |
146 | sendMail.setMessage(ftext); | 172 | sendMail.setMessage(ftext); |
147 | 173 | ||
148 | Composer *composer = new Composer(0, 0, Qt::WType_Modal); | 174 | Composer composer(this, 0, true); |
149 | composer->setSendMail(sendMail); | 175 | composer.setSendMail(sendMail); |
150 | composer->showMaximized(); | 176 | composer.showMaximized(); |
151 | composer->show(); | 177 | composer.exec(); |
152 | } | 178 | } |
153 | 179 | ||
154 | void ViewMail::slotIMAPUid(IMAPResponse &response) | 180 | void ViewMail::slotIMAPUid(IMAPResponse &response) |
155 | { | 181 | { |
156 | disconnect(_handler, SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPUid(IMAPResponse &))); | 182 | disconnect(_handler, SIGNAL(gotResponse(IMAPResponse &)), this, SLOT(slotIMAPUid(IMAPResponse &))); |
157 | 183 | ||
diff --git a/noncore/unsupported/mail2/viewmail.h b/noncore/unsupported/mail2/viewmail.h index a013e43..efc2300 100644 --- a/noncore/unsupported/mail2/viewmail.h +++ b/noncore/unsupported/mail2/viewmail.h | |||
@@ -40,24 +40,29 @@ private: | |||
40 | class ViewMail : public ViewMailBase | 40 | class ViewMail : public ViewMailBase |
41 | { | 41 | { |
42 | Q_OBJECT | 42 | Q_OBJECT |
43 | 43 | ||
44 | public: | 44 | public: |
45 | ViewMail(IMAPResponseFETCH &mail, IMAPHandler *handler, QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal); | 45 | ViewMail(IMAPResponseFETCH &mail, IMAPHandler *handler, QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal); |
46 | ~ViewMail(); | ||
47 | |||
48 | void hide(); | ||
49 | void exec(); | ||
46 | 50 | ||
47 | protected: | 51 | protected: |
48 | //void fillList(IMAPResponseBODYSTRUCTURE &structure); | 52 | //void fillList(IMAPResponseBODYSTRUCTURE &structure); |
49 | QString deHtml(const QString &string); | 53 | QString deHtml(const QString &string); |
50 | 54 | ||
51 | protected slots: | 55 | protected slots: |
52 | void slotReply(); | 56 | void slotReply(); |
53 | void slotForward(); | 57 | void slotForward(); |
54 | 58 | ||
55 | void slotIMAPUid(IMAPResponse &response); | 59 | void slotIMAPUid(IMAPResponse &response); |
56 | 60 | ||
57 | private: | 61 | private: |
62 | bool _inLoop; | ||
58 | IMAPResponseFETCH _mail; | 63 | IMAPResponseFETCH _mail; |
59 | IMAPHandler *_handler; | 64 | IMAPHandler *_handler; |
60 | QString _mailHtml; | 65 | QString _mailHtml; |
61 | bool _gotBody; | 66 | bool _gotBody; |
62 | 67 | ||
63 | }; | 68 | }; |