diff --git a/src/vmime/net/imap/IMAPConnection.cpp b/src/vmime/net/imap/IMAPConnection.cpp index 71e409c3..2de93314 100644 --- a/src/vmime/net/imap/IMAPConnection.cpp +++ b/src/vmime/net/imap/IMAPConnection.cpp @@ -93,9 +93,9 @@ IMAPConnection::~IMAPConnection() else if (m_socket) internalDisconnect(); } - catch (vmime::exception&) + catch (...) { - // Ignore + // Don't throw in destructor } } diff --git a/src/vmime/net/imap/IMAPFolder.cpp b/src/vmime/net/imap/IMAPFolder.cpp index 00fee93c..3c55dbad 100644 --- a/src/vmime/net/imap/IMAPFolder.cpp +++ b/src/vmime/net/imap/IMAPFolder.cpp @@ -65,19 +65,26 @@ IMAPFolder::IMAPFolder(const folder::path& path, shared_ptr store, s IMAPFolder::~IMAPFolder() { - shared_ptr store = m_store.lock(); - - if (store) + try { - if (m_open) - close(false); + shared_ptr store = m_store.lock(); - store->unregisterFolder(this); + if (store) + { + if (m_open) + close(false); + + store->unregisterFolder(this); + } + else if (m_open) + { + m_connection = null; + onClose(); + } } - else if (m_open) + catch (...) { - m_connection = null; - onClose(); + // Don't throw in destructor } } diff --git a/src/vmime/net/imap/IMAPMessage.cpp b/src/vmime/net/imap/IMAPMessage.cpp index aa6b45ec..c79c4ffa 100644 --- a/src/vmime/net/imap/IMAPMessage.cpp +++ b/src/vmime/net/imap/IMAPMessage.cpp @@ -115,10 +115,17 @@ IMAPMessage::IMAPMessage(shared_ptr folder, const int num, const ui IMAPMessage::~IMAPMessage() { - shared_ptr folder = m_folder.lock(); + try + { + shared_ptr folder = m_folder.lock(); - if (folder) - folder->unregisterMessage(this); + if (folder) + folder->unregisterMessage(this); + } + catch (...) + { + // Don't throw in destructor + } } diff --git a/src/vmime/net/imap/IMAPStore.cpp b/src/vmime/net/imap/IMAPStore.cpp index a2930c66..28ba34e8 100644 --- a/src/vmime/net/imap/IMAPStore.cpp +++ b/src/vmime/net/imap/IMAPStore.cpp @@ -57,9 +57,9 @@ IMAPStore::~IMAPStore() if (isConnected()) disconnect(); } - catch (vmime::exception&) + catch (...) { - // Ignore + // Don't throw in destructor } } @@ -120,15 +120,7 @@ void IMAPStore::connect() m_connection = make_shared (dynamicCast (shared_from_this()), getAuthenticator()); - try - { - m_connection->connect(); - } - catch (std::exception&) - { - m_connection = null; - throw; - } + m_connection->connect(); } diff --git a/src/vmime/net/maildir/maildirFolder.cpp b/src/vmime/net/maildir/maildirFolder.cpp index eb0eb9fd..87200473 100644 --- a/src/vmime/net/maildir/maildirFolder.cpp +++ b/src/vmime/net/maildir/maildirFolder.cpp @@ -60,18 +60,25 @@ maildirFolder::maildirFolder(const folder::path& path, shared_ptr maildirFolder::~maildirFolder() { - shared_ptr store = m_store.lock(); - - if (store) + try { - if (m_open) + shared_ptr store = m_store.lock(); + + if (store) + { + if (m_open) + close(false); + + store->unregisterFolder(this); + } + else if (m_open) + { close(false); - - store->unregisterFolder(this); + } } - else if (m_open) + catch (...) { - close(false); + // Don't throw in destructor } } diff --git a/src/vmime/net/maildir/maildirMessage.cpp b/src/vmime/net/maildir/maildirMessage.cpp index a14f067e..541c58b6 100644 --- a/src/vmime/net/maildir/maildirMessage.cpp +++ b/src/vmime/net/maildir/maildirMessage.cpp @@ -58,10 +58,17 @@ maildirMessage::maildirMessage(shared_ptr folder, const int num) maildirMessage::~maildirMessage() { - shared_ptr folder = m_folder.lock(); + try + { + shared_ptr folder = m_folder.lock(); - if (folder) - folder->unregisterMessage(this); + if (folder) + folder->unregisterMessage(this); + } + catch (...) + { + // Don't throw in destructor + } } diff --git a/src/vmime/net/maildir/maildirStore.cpp b/src/vmime/net/maildir/maildirStore.cpp index 87e733e2..606fbead 100644 --- a/src/vmime/net/maildir/maildirStore.cpp +++ b/src/vmime/net/maildir/maildirStore.cpp @@ -65,9 +65,9 @@ maildirStore::~maildirStore() if (isConnected()) disconnect(); } - catch (vmime::exception&) + catch (...) { - // Ignore + // Don't throw in destructor } } diff --git a/src/vmime/net/pop3/POP3Connection.cpp b/src/vmime/net/pop3/POP3Connection.cpp index 3f2cbe0b..a503ba88 100644 --- a/src/vmime/net/pop3/POP3Connection.cpp +++ b/src/vmime/net/pop3/POP3Connection.cpp @@ -83,9 +83,9 @@ POP3Connection::~POP3Connection() else if (m_socket) internalDisconnect(); } - catch (vmime::exception&) + catch (...) { - // Ignore + // Don't throw in destructor } } diff --git a/src/vmime/net/pop3/POP3Folder.cpp b/src/vmime/net/pop3/POP3Folder.cpp index 78400fce..435a57e9 100644 --- a/src/vmime/net/pop3/POP3Folder.cpp +++ b/src/vmime/net/pop3/POP3Folder.cpp @@ -56,18 +56,25 @@ POP3Folder::POP3Folder(const folder::path& path, shared_ptr store) POP3Folder::~POP3Folder() { - shared_ptr store = m_store.lock(); - - if (store) + try { - if (m_open) - close(false); + shared_ptr store = m_store.lock(); - store->unregisterFolder(this); + if (store) + { + if (m_open) + close(false); + + store->unregisterFolder(this); + } + else if (m_open) + { + onClose(); + } } - else if (m_open) + catch (...) { - onClose(); + // Don't throw in destructor } } diff --git a/src/vmime/net/pop3/POP3Message.cpp b/src/vmime/net/pop3/POP3Message.cpp index 0b7e6d37..888415e3 100644 --- a/src/vmime/net/pop3/POP3Message.cpp +++ b/src/vmime/net/pop3/POP3Message.cpp @@ -53,10 +53,17 @@ POP3Message::POP3Message(shared_ptr folder, const int num) POP3Message::~POP3Message() { - shared_ptr folder = m_folder.lock(); + try + { + shared_ptr folder = m_folder.lock(); - if (folder) - folder->unregisterMessage(this); + if (folder) + folder->unregisterMessage(this); + } + catch (...) + { + // Don't throw in destructor + } } diff --git a/src/vmime/net/pop3/POP3Store.cpp b/src/vmime/net/pop3/POP3Store.cpp index e6e95b1b..63448d4f 100644 --- a/src/vmime/net/pop3/POP3Store.cpp +++ b/src/vmime/net/pop3/POP3Store.cpp @@ -55,9 +55,9 @@ POP3Store::~POP3Store() if (isConnected()) disconnect(); } - catch (vmime::exception&) + catch (...) { - // Ignore + // Don't throw in destructor } } @@ -113,15 +113,7 @@ void POP3Store::connect() m_connection = make_shared (dynamicCast (shared_from_this()), getAuthenticator()); - try - { - m_connection->connect(); - } - catch (std::exception&) - { - m_connection = null; - throw; - } + m_connection->connect(); } diff --git a/src/vmime/net/sendmail/sendmailTransport.cpp b/src/vmime/net/sendmail/sendmailTransport.cpp index 8ef18e3b..822e1114 100644 --- a/src/vmime/net/sendmail/sendmailTransport.cpp +++ b/src/vmime/net/sendmail/sendmailTransport.cpp @@ -71,9 +71,9 @@ sendmailTransport::~sendmailTransport() if (isConnected()) disconnect(); } - catch (vmime::exception&) + catch (...) { - // Ignore + // Don't throw in destructor } } diff --git a/src/vmime/net/smtp/SMTPConnection.cpp b/src/vmime/net/smtp/SMTPConnection.cpp index 60c8515d..4832929c 100644 --- a/src/vmime/net/smtp/SMTPConnection.cpp +++ b/src/vmime/net/smtp/SMTPConnection.cpp @@ -84,9 +84,9 @@ SMTPConnection::~SMTPConnection() else if (m_socket) internalDisconnect(); } - catch (vmime::exception&) + catch (...) { - // Ignore + // Don't throw in destructor } } diff --git a/src/vmime/net/smtp/SMTPTransport.cpp b/src/vmime/net/smtp/SMTPTransport.cpp index ed775442..2af6a195 100644 --- a/src/vmime/net/smtp/SMTPTransport.cpp +++ b/src/vmime/net/smtp/SMTPTransport.cpp @@ -64,9 +64,9 @@ SMTPTransport::~SMTPTransport() if (isConnected()) disconnect(); } - catch (vmime::exception&) + catch (...) { - // Ignore + // Don't throw in destructor } } @@ -91,15 +91,7 @@ void SMTPTransport::connect() m_connection = make_shared (dynamicCast (shared_from_this()), getAuthenticator()); - try - { - m_connection->connect(); - } - catch (std::exception&) - { - m_connection = null; - throw; - } + m_connection->connect(); } diff --git a/src/vmime/net/tls/gnutls/TLSSession_GnuTLS.cpp b/src/vmime/net/tls/gnutls/TLSSession_GnuTLS.cpp index 1c520ed1..45cdad61 100644 --- a/src/vmime/net/tls/gnutls/TLSSession_GnuTLS.cpp +++ b/src/vmime/net/tls/gnutls/TLSSession_GnuTLS.cpp @@ -257,12 +257,19 @@ TLSSession_GnuTLS::TLSSession_GnuTLS(const TLSSession_GnuTLS&) TLSSession_GnuTLS::~TLSSession_GnuTLS() { - if (m_gnutlsSession) + try { - gnutls_deinit(*m_gnutlsSession); + if (m_gnutlsSession) + { + gnutls_deinit(*m_gnutlsSession); - delete m_gnutlsSession; - m_gnutlsSession = NULL; + delete m_gnutlsSession; + m_gnutlsSession = NULL; + } + } + catch (...) + { + // Don't throw in destructor } }