Don't throw in destructor.

This commit is contained in:
Vincent Richard 2014-11-02 13:09:59 +01:00
parent a32bb6c954
commit 31df6171de
15 changed files with 106 additions and 81 deletions

View File

@ -93,9 +93,9 @@ IMAPConnection::~IMAPConnection()
else if (m_socket)
internalDisconnect();
}
catch (vmime::exception&)
catch (...)
{
// Ignore
// Don't throw in destructor
}
}

View File

@ -65,6 +65,8 @@ IMAPFolder::IMAPFolder(const folder::path& path, shared_ptr <IMAPStore> store, s
IMAPFolder::~IMAPFolder()
{
try
{
shared_ptr <IMAPStore> store = m_store.lock();
if (store)
@ -79,6 +81,11 @@ IMAPFolder::~IMAPFolder()
m_connection = null;
onClose();
}
}
catch (...)
{
// Don't throw in destructor
}
}

View File

@ -115,10 +115,17 @@ IMAPMessage::IMAPMessage(shared_ptr <IMAPFolder> folder, const int num, const ui
IMAPMessage::~IMAPMessage()
{
try
{
shared_ptr <IMAPFolder> folder = m_folder.lock();
if (folder)
folder->unregisterMessage(this);
}
catch (...)
{
// Don't throw in destructor
}
}

View File

@ -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 <IMAPConnection>
(dynamicCast <IMAPStore>(shared_from_this()), getAuthenticator());
try
{
m_connection->connect();
}
catch (std::exception&)
{
m_connection = null;
throw;
}
}

View File

@ -60,6 +60,8 @@ maildirFolder::maildirFolder(const folder::path& path, shared_ptr <maildirStore>
maildirFolder::~maildirFolder()
{
try
{
shared_ptr <maildirStore> store = m_store.lock();
if (store)
@ -73,6 +75,11 @@ maildirFolder::~maildirFolder()
{
close(false);
}
}
catch (...)
{
// Don't throw in destructor
}
}

View File

@ -58,10 +58,17 @@ maildirMessage::maildirMessage(shared_ptr <maildirFolder> folder, const int num)
maildirMessage::~maildirMessage()
{
try
{
shared_ptr <maildirFolder> folder = m_folder.lock();
if (folder)
folder->unregisterMessage(this);
}
catch (...)
{
// Don't throw in destructor
}
}

View File

@ -65,9 +65,9 @@ maildirStore::~maildirStore()
if (isConnected())
disconnect();
}
catch (vmime::exception&)
catch (...)
{
// Ignore
// Don't throw in destructor
}
}

View File

@ -83,9 +83,9 @@ POP3Connection::~POP3Connection()
else if (m_socket)
internalDisconnect();
}
catch (vmime::exception&)
catch (...)
{
// Ignore
// Don't throw in destructor
}
}

View File

@ -56,6 +56,8 @@ POP3Folder::POP3Folder(const folder::path& path, shared_ptr <POP3Store> store)
POP3Folder::~POP3Folder()
{
try
{
shared_ptr <POP3Store> store = m_store.lock();
if (store)
@ -69,6 +71,11 @@ POP3Folder::~POP3Folder()
{
onClose();
}
}
catch (...)
{
// Don't throw in destructor
}
}

View File

@ -53,10 +53,17 @@ POP3Message::POP3Message(shared_ptr <POP3Folder> folder, const int num)
POP3Message::~POP3Message()
{
try
{
shared_ptr <POP3Folder> folder = m_folder.lock();
if (folder)
folder->unregisterMessage(this);
}
catch (...)
{
// Don't throw in destructor
}
}

View File

@ -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 <POP3Connection>
(dynamicCast <POP3Store>(shared_from_this()), getAuthenticator());
try
{
m_connection->connect();
}
catch (std::exception&)
{
m_connection = null;
throw;
}
}

View File

@ -71,9 +71,9 @@ sendmailTransport::~sendmailTransport()
if (isConnected())
disconnect();
}
catch (vmime::exception&)
catch (...)
{
// Ignore
// Don't throw in destructor
}
}

View File

@ -84,9 +84,9 @@ SMTPConnection::~SMTPConnection()
else if (m_socket)
internalDisconnect();
}
catch (vmime::exception&)
catch (...)
{
// Ignore
// Don't throw in destructor
}
}

View File

@ -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 <SMTPConnection>
(dynamicCast <SMTPTransport>(shared_from_this()), getAuthenticator());
try
{
m_connection->connect();
}
catch (std::exception&)
{
m_connection = null;
throw;
}
}

View File

@ -257,6 +257,8 @@ TLSSession_GnuTLS::TLSSession_GnuTLS(const TLSSession_GnuTLS&)
TLSSession_GnuTLS::~TLSSession_GnuTLS()
{
try
{
if (m_gnutlsSession)
{
gnutls_deinit(*m_gnutlsSession);
@ -264,6 +266,11 @@ TLSSession_GnuTLS::~TLSSession_GnuTLS()
delete m_gnutlsSession;
m_gnutlsSession = NULL;
}
}
catch (...)
{
// Don't throw in destructor
}
}