From a2617235fed97ea21fbec81fdda10fbd5a03f3e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Obiltschnig?= Date: Mon, 29 Sep 2014 12:09:01 +0200 Subject: [PATCH] #538 more dtor fixes and some style fixes along the way --- Data/ODBC/src/Binder.cpp | 10 +++--- Data/ODBC/src/ODBCStatementImpl.cpp | 4 +-- Data/include/Poco/Data/Binding.h | 20 +++++------ Data/src/Row.cpp | 3 +- Foundation/include/Poco/ScopedUnlock.h | 9 ++++- Foundation/src/SortedDirectoryIterator.cpp | 1 + Foundation/src/SplitterChannel.cpp | 9 ++++- MongoDB/src/Cursor.cpp | 9 ++++- Net/src/FTPClientSession.cpp | 39 +++++++++++++--------- NetSSL_OpenSSL/src/SecureSocketImpl.cpp | 1 + 10 files changed, 68 insertions(+), 37 deletions(-) diff --git a/Data/ODBC/src/Binder.cpp b/Data/ODBC/src/Binder.cpp index c043814ff..38b712149 100644 --- a/Data/ODBC/src/Binder.cpp +++ b/Data/ODBC/src/Binder.cpp @@ -51,23 +51,23 @@ void Binder::freeMemory() { LengthVec::iterator itLen = _lengthIndicator.begin(); LengthVec::iterator itLenEnd = _lengthIndicator.end(); - for(; itLen != itLenEnd; ++itLen) delete *itLen; + for (; itLen != itLenEnd; ++itLen) delete *itLen; TimeMap::iterator itT = _times.begin(); TimeMap::iterator itTEnd = _times.end(); - for(; itT != itTEnd; ++itT) delete itT->first; + for (; itT != itTEnd; ++itT) delete itT->first; DateMap::iterator itD = _dates.begin(); DateMap::iterator itDEnd = _dates.end(); - for(; itD != itDEnd; ++itD) delete itD->first; + for (; itD != itDEnd; ++itD) delete itD->first; TimestampMap::iterator itTS = _timestamps.begin(); TimestampMap::iterator itTSEnd = _timestamps.end(); - for(; itTS != itTSEnd; ++itTS) delete itTS->first; + for (; itTS != itTSEnd; ++itTS) delete itTS->first; StringMap::iterator itStr = _strings.begin(); StringMap::iterator itStrEnd = _strings.end(); - for(; itStr != itStrEnd; ++itStr) std::free(itStr->first); + for (; itStr != itStrEnd; ++itStr) std::free(itStr->first); CharPtrVec::iterator itChr = _charPtrs.begin(); CharPtrVec::iterator endChr = _charPtrs.end(); diff --git a/Data/ODBC/src/ODBCStatementImpl.cpp b/Data/ODBC/src/ODBCStatementImpl.cpp index 0a3ab4953..c48343362 100644 --- a/Data/ODBC/src/ODBCStatementImpl.cpp +++ b/Data/ODBC/src/ODBCStatementImpl.cpp @@ -64,11 +64,11 @@ ODBCStatementImpl::~ODBCStatementImpl() { ColumnPtrVecVec::iterator it = _columnPtrs.begin(); ColumnPtrVecVec::iterator end = _columnPtrs.end(); - for(; it != end; ++it) + for (; it != end; ++it) { ColumnPtrVec::iterator itC = it->begin(); ColumnPtrVec::iterator endC = it->end(); - for(; itC != endC; ++itC) delete *itC; + for (; itC != endC; ++itC) delete *itC; } } diff --git a/Data/include/Poco/Data/Binding.h b/Data/include/Poco/Data/Binding.h index 70758f98f..07f2831a7 100644 --- a/Data/include/Poco/Data/Binding.h +++ b/Data/include/Poco/Data/Binding.h @@ -140,7 +140,7 @@ public: } ~CopyBinding() - /// Destroys the Binding. + /// Destroys the CopyBinding. { } @@ -264,7 +264,7 @@ public: } ~CopyBinding() - /// Destroys the Binding. + /// Destroys the CopyBinding. { } @@ -396,7 +396,7 @@ public: } ~CopyBinding() - /// Destroys the Binding. + /// Destroys the CopyBinding. { } @@ -559,7 +559,7 @@ public: } ~CopyBinding() - /// Destroys the Binding. + /// Destroys the CopyBinding. { } @@ -689,7 +689,7 @@ public: } ~CopyBinding() - /// Destroys the Binding. + /// Destroys the CopyBinding. { } @@ -819,7 +819,7 @@ public: } ~CopyBinding() - /// Destroys the Binding. + /// Destroys the CopyBinding. { } @@ -949,7 +949,7 @@ public: } ~CopyBinding() - /// Destroys the Binding. + /// Destroys the CopyBinding. { } @@ -1079,7 +1079,7 @@ public: } ~CopyBinding() - /// Destroys the Binding. + /// Destroys the CopyBinding. { } @@ -1209,7 +1209,7 @@ public: } ~CopyBinding() - /// Destroys the Binding. + /// Destroys the CopyBinding. { } @@ -1339,7 +1339,7 @@ public: } ~CopyBinding() - /// Destroys the Binding. + /// Destroys the CopyBinding. { } diff --git a/Data/src/Row.cpp b/Data/src/Row.cpp index 032d0e68c..7006a171c 100644 --- a/Data/src/Row.cpp +++ b/Data/src/Row.cpp @@ -86,7 +86,8 @@ Poco::Dynamic::Var& Row::get(std::size_t col) try { return _values.at(col); - }catch (std::out_of_range& re) + } + catch (std::out_of_range& re) { throw RangeException(re.what()); } diff --git a/Foundation/include/Poco/ScopedUnlock.h b/Foundation/include/Poco/ScopedUnlock.h index ef20d88ee..b301d0050 100644 --- a/Foundation/include/Poco/ScopedUnlock.h +++ b/Foundation/include/Poco/ScopedUnlock.h @@ -41,7 +41,14 @@ public: } inline ~ScopedUnlock() { - _mutex.lock(); + try + { + _mutex.lock(); + } + catch (...) + { + poco_unexpected(); + } } private: diff --git a/Foundation/src/SortedDirectoryIterator.cpp b/Foundation/src/SortedDirectoryIterator.cpp index 3d4e7bf12..69fe8fdf3 100644 --- a/Foundation/src/SortedDirectoryIterator.cpp +++ b/Foundation/src/SortedDirectoryIterator.cpp @@ -62,6 +62,7 @@ SortedDirectoryIterator::~SortedDirectoryIterator() { } + SortedDirectoryIterator& SortedDirectoryIterator::operator ++() { if (!_is_finished) diff --git a/Foundation/src/SplitterChannel.cpp b/Foundation/src/SplitterChannel.cpp index 2b264c566..05d296fd3 100644 --- a/Foundation/src/SplitterChannel.cpp +++ b/Foundation/src/SplitterChannel.cpp @@ -29,7 +29,14 @@ SplitterChannel::SplitterChannel() SplitterChannel::~SplitterChannel() { - close(); + try + { + close(); + } + catch (...) + { + poco_unexpected(); + } } diff --git a/MongoDB/src/Cursor.cpp b/MongoDB/src/Cursor.cpp index 201623a40..8ce5b4882 100644 --- a/MongoDB/src/Cursor.cpp +++ b/MongoDB/src/Cursor.cpp @@ -39,7 +39,14 @@ Cursor::Cursor(const std::string& fullCollectionName, QueryRequest::Flags flags) Cursor::~Cursor() { - poco_assert_dbg(!_response.cursorID()); + try + { + poco_assert_dbg(!_response.cursorID()); + + } + catch (...) + { + } } diff --git a/Net/src/FTPClientSession.cpp b/Net/src/FTPClientSession.cpp index 5cce5b99e..24131cf2a 100644 --- a/Net/src/FTPClientSession.cpp +++ b/Net/src/FTPClientSession.cpp @@ -64,28 +64,33 @@ FTPClientSession::FTPClientSession(const std::string& host, Poco::UInt16 port, const std::string& username, const std::string& password): - _host(host), - _port(port), - _pControlSocket(new DialogSocket(SocketAddress(host, port))), - _pDataStream(0), - _passiveMode(true), - _fileType(TYPE_BINARY), - _supports1738(true), - _serverReady(false), - _isLoggedIn(false), - _timeout(DEFAULT_TIMEOUT) - { + _host(host), + _port(port), + _pControlSocket(new DialogSocket(SocketAddress(host, port))), + _pDataStream(0), + _passiveMode(true), + _fileType(TYPE_BINARY), + _supports1738(true), + _serverReady(false), + _isLoggedIn(false), + _timeout(DEFAULT_TIMEOUT) +{ if (!username.empty()) login(username, password); else _pControlSocket->setReceiveTimeout(_timeout); - } +} FTPClientSession::~FTPClientSession() +{ + try { - try { close(); } - catch (...) { } + close(); + } + catch (...) + { + } } @@ -126,7 +131,9 @@ void FTPClientSession::open(const std::string& host, _host = host; _port = port; if (!username.empty()) + { login(username, password); + } else { _pControlSocket = new DialogSocket(SocketAddress(_host, _port)); @@ -168,12 +175,12 @@ void FTPClientSession::login(const std::string& username, const std::string& pas void FTPClientSession::logout() - { +{ if (!isOpen()) throw FTPException("Connection is closed."); if (_isLoggedIn) - { + { try { endTransfer(); } catch (...) { } std::string response; diff --git a/NetSSL_OpenSSL/src/SecureSocketImpl.cpp b/NetSSL_OpenSSL/src/SecureSocketImpl.cpp index 489b2d6e8..be92b630e 100644 --- a/NetSSL_OpenSSL/src/SecureSocketImpl.cpp +++ b/NetSSL_OpenSSL/src/SecureSocketImpl.cpp @@ -66,6 +66,7 @@ SecureSocketImpl::~SecureSocketImpl() } catch (...) { + poco_unexpected(); } }