author | leseb <leseb> | 2002-06-16 16:15:47 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-06-16 16:15:47 (UTC) |
commit | ea69cfbbde29fef2f792d1eab702699aada088bf (patch) (side-by-side diff) | |
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 @@ -8,2 +8,3 @@ #include <qlabel.h> +#include <qapplication.h> @@ -27,3 +28,3 @@ AttachViewItem::AttachViewItem(QListView *parent, Attachment &attachment) Composer::Composer(QWidget *parent, const char *name, WFlags fl) - : ComposerBase(parent, name, fl) + : ComposerBase(parent, name, fl), _inLoop(false) { @@ -45,2 +46,27 @@ Composer::Composer(QWidget *parent, const char *name, WFlags fl) +Composer::~Composer() +{ + hide(); +} + +void Composer::hide() +{ + QWidget::hide(); + + if (_inLoop) { + _inLoop = false; + qApp->exit_loop(); + } +} + +void Composer::exec() +{ + show(); + + if (!_inLoop) { + _inLoop = true; + qApp->enter_loop(); + } +} + void Composer::setSendMail(SendMail &sendMail) 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 @@ -28,2 +28,6 @@ public: Composer(QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal); + ~Composer(); + + void hide(); + void exec(); @@ -47,2 +51,3 @@ protected: private: + bool _inLoop; QString _inReplyTo; 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 @@ -38,5 +38,5 @@ void MainWindow::slotCompose() { - Composer *composer = new Composer(); - composer->showMaximized(); - composer->show(); + Composer composer(this, 0, true); + composer.showMaximized(); + composer.exec(); } @@ -45,5 +45,5 @@ void MainWindow::slotSearch() { - SearchDiag *searchDiag = new SearchDiag(this, 0, true); - searchDiag->showMaximized(); - searchDiag->show(); + SearchDiag searchDiag(this, 0, true); + searchDiag.showMaximized(); + searchDiag.exec(); } @@ -52,7 +52,7 @@ void MainWindow::slotConfigure() { - ConfigDiag *configDiag = new ConfigDiag(this, 0, true); - configDiag->showMaximized(); - configDiag->show(); + ConfigDiag configDiag(this, 0, true); + configDiag.showMaximized(); + configDiag.exec(); - connect(configDiag, SIGNAL(changed()), folderView, SLOT(update())); + connect(&configDiag, SIGNAL(changed()), folderView, SLOT(update())); } @@ -61,5 +61,5 @@ void MainWindow::mailClicked(IMAPResponseFETCH mail, IMAPHandler *handler) { - ViewMail *viewMail = new ViewMail(mail, handler); - viewMail->showMaximized(); - viewMail->show(); + ViewMail viewMail(mail, handler, this, 0, true); + viewMail.showMaximized(); + viewMail.exec(); } 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 @@ -114,5 +114,5 @@ void SearchDiag::slotMailClicked(IMAPResponseFETCH fetch, IMAPHandler *) { - ViewMail *viewMail = new ViewMail(fetch, _folder.topFolder().handler()); - viewMail->showMaximized(); - viewMail->show(); + ViewMail viewMail(fetch, _folder.topFolder().handler(), this, 0, true); + viewMail.showMaximized(); + viewMail.exec(); } 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 @@ -3,2 +3,3 @@ #include <qaction.h> +#include <qapplication.h> @@ -25,3 +26,3 @@ AttachItem::AttachItem(QListViewItem *parent, AttachItemStore &attachItemStore) ViewMail::ViewMail(IMAPResponseFETCH &mail, IMAPHandler *handler, QWidget *parent, const char *name, WFlags fl) - : ViewMailBase(parent, name, fl), _mail(mail), _handler(handler) + : ViewMailBase(parent, name, fl), _inLoop(false), _mail(mail), _handler(handler) { @@ -63,2 +64,27 @@ ViewMail::ViewMail(IMAPResponseFETCH &mail, IMAPHandler *handler, QWidget *paren +ViewMail::~ViewMail() +{ + hide(); +} + +void ViewMail::hide() +{ + QWidget::hide(); + + if (_inLoop) { + _inLoop = false; + qApp->exit_loop(); + } +} + +void ViewMail::exec() +{ + show(); + + if (!_inLoop) { + _inLoop = true; + qApp->enter_loop(); + } +} + QString ViewMail::deHtml(const QString &string) @@ -103,6 +129,6 @@ void ViewMail::slotReply() - Composer *composer = new Composer(0, 0, Qt::WType_Modal); - composer->setSendMail(sendMail); - composer->showMaximized(); - composer->show(); + Composer composer(this, 0, true); + composer.setSendMail(sendMail); + composer.showMaximized(); + composer.exec(); } @@ -147,6 +173,6 @@ void ViewMail::slotForward() - Composer *composer = new Composer(0, 0, Qt::WType_Modal); - composer->setSendMail(sendMail); - composer->showMaximized(); - composer->show(); + Composer composer(this, 0, true); + composer.setSendMail(sendMail); + composer.showMaximized(); + composer.exec(); } 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 @@ -45,2 +45,6 @@ public: ViewMail(IMAPResponseFETCH &mail, IMAPHandler *handler, QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal); + ~ViewMail(); + + void hide(); + void exec(); @@ -57,2 +61,3 @@ protected slots: private: + bool _inLoop; IMAPResponseFETCH _mail; |