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

@ -64,6 +64,8 @@ IMAPFolder::IMAPFolder(const folder::path& path, shared_ptr <IMAPStore> store, s
IMAPFolder::~IMAPFolder()
{
try
{
shared_ptr <IMAPStore> store = m_store.lock();
@ -80,6 +82,11 @@ IMAPFolder::~IMAPFolder()
onClose();
}
}
catch (...)
{
// Don't throw in destructor
}
}
int IMAPFolder::getMode() const

View File

@ -114,12 +114,19 @@ 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
}
}
void IMAPMessage::onFolderClosed()

View File

@ -57,9 +57,9 @@ IMAPStore::~IMAPStore()
if (isConnected())
disconnect();
}
catch (vmime::exception&)
catch (...)
{
// Ignore
// Don't throw in destructor
}
}
@ -120,16 +120,8 @@ 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;
}
}
bool IMAPStore::isConnected() const

View File

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

View File

@ -57,12 +57,19 @@ 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
}
}
void maildirMessage::onFolderClosed()

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

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

View File

@ -52,12 +52,19 @@ 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
}
}
void POP3Message::onFolderClosed()

View File

@ -55,9 +55,9 @@ POP3Store::~POP3Store()
if (isConnected())
disconnect();
}
catch (vmime::exception&)
catch (...)
{
// Ignore
// Don't throw in destructor
}
}
@ -113,16 +113,8 @@ 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;
}
}
bool POP3Store::isPOP3S() const

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,16 +91,8 @@ 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;
}
}
bool SMTPTransport::isConnected() const

View File

@ -256,6 +256,8 @@ TLSSession_GnuTLS::TLSSession_GnuTLS(const TLSSession_GnuTLS&)
TLSSession_GnuTLS::~TLSSession_GnuTLS()
{
try
{
if (m_gnutlsSession)
{
@ -265,6 +267,11 @@ TLSSession_GnuTLS::~TLSSession_GnuTLS()
m_gnutlsSession = NULL;
}
}
catch (...)
{
// Don't throw in destructor
}
}
shared_ptr <TLSSocket> TLSSession_GnuTLS::getSocket(shared_ptr <socket> sok)