dbaccess/source/core/api/RowSet.cxx | 8 ++++---- dbaccess/source/core/api/RowSetBase.cxx | 10 +++------- dbaccess/source/core/api/RowSetBase.hxx | 4 ++-- dbaccess/source/core/api/RowSetCache.cxx | 9 ++++----- dbaccess/source/core/api/RowSetCache.hxx | 4 ++-- dbaccess/source/core/api/preparedstatement.cxx | 6 ++---- dbaccess/source/core/api/resultset.cxx | 10 ++++------ dbaccess/source/core/api/resultset.hxx | 2 +- dbaccess/source/core/dataaccess/connection.cxx | 22 ++++++++++------------ dbaccess/source/core/dataaccess/connection.hxx | 4 ++-- dbaccess/source/core/dataaccess/intercept.cxx | 8 +++----- dbaccess/source/core/dataaccess/intercept.hxx | 4 ++-- dbaccess/source/core/inc/preparedstatement.hxx | 2 +- 13 files changed, 40 insertions(+), 53 deletions(-)
New commits: commit 28799d303c84c7ec76c657043c7394ceec4b8416 Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Thu Mar 1 09:12:07 2018 +0200 loplugin:useuniqueptr in dbaccess(2) Change-Id: I49e69d8ab5b7a9ce699a2e0e0cad7ce4c4d0b62f Reviewed-on: https://gerrit.libreoffice.org/50714 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/dbaccess/source/core/api/RowSetCache.cxx b/dbaccess/source/core/api/RowSetCache.cxx index 08a82c9dcb91..53b9492021f1 100644 --- a/dbaccess/source/core/api/RowSetCache.cxx +++ b/dbaccess/source/core/api/RowSetCache.cxx @@ -353,18 +353,17 @@ ORowSetCache::~ORowSetCache() if(m_pMatrix) { m_pMatrix->clear(); - delete m_pMatrix; + m_pMatrix.reset(); } if(m_pInsertMatrix) { m_pInsertMatrix->clear(); - delete m_pInsertMatrix; + m_pInsertMatrix.reset(); } m_xSet = WeakReference< XResultSet>(); m_xMetaData = nullptr; m_aUpdateTable = nullptr; - } void ORowSetCache::setFetchSize(sal_Int32 _nSize) @@ -375,11 +374,11 @@ void ORowSetCache::setFetchSize(sal_Int32 _nSize) m_nFetchSize = _nSize; if(!m_pMatrix) { - m_pMatrix = new ORowSetMatrix(_nSize); + m_pMatrix.reset( new ORowSetMatrix(_nSize) ); m_aMatrixIter = m_pMatrix->end(); m_aMatrixEnd = m_pMatrix->end(); - m_pInsertMatrix = new ORowSetMatrix(1); // a little bit overkill but ??? :-) + m_pInsertMatrix.reset( new ORowSetMatrix(1) ); // a little bit overkill but ??? :-) m_aInsertRow = m_pInsertMatrix->end(); } else diff --git a/dbaccess/source/core/api/RowSetCache.hxx b/dbaccess/source/core/api/RowSetCache.hxx index 2a90278afd5f..4a8373d1ee85 100644 --- a/dbaccess/source/core/api/RowSetCache.hxx +++ b/dbaccess/source/core/api/RowSetCache.hxx @@ -65,13 +65,13 @@ namespace dbaccess rtl::Reference<OCacheSet> m_xCacheSet; // is a bookmarkable, keyset or static resultset - ORowSetMatrix* m_pMatrix; // represent the table struct + std::unique_ptr<ORowSetMatrix> m_pMatrix; // represent the table struct ORowSetMatrix::iterator m_aMatrixIter; // represent a row of the table ORowSetMatrix::iterator m_aMatrixEnd; // present the row behind the last row of the table ORowSetCacheMap m_aCacheIterators; TOldRowSetRows m_aOldRows; - ORowSetMatrix* m_pInsertMatrix; // represent the rows which should be inserted normally this is only one + std::unique_ptr<ORowSetMatrix> m_pInsertMatrix; // represent the rows which should be inserted normally this is only one ORowSetMatrix::iterator m_aInsertRow; // represent a insert row connectivity::OSQLTable m_aUpdateTable; // used for updates/deletes and inserts diff --git a/dbaccess/source/core/dataaccess/connection.cxx b/dbaccess/source/core/dataaccess/connection.cxx index 4e5d6fd1bdc8..c0fc854971f5 100644 --- a/dbaccess/source/core/dataaccess/connection.cxx +++ b/dbaccess/source/core/dataaccess/connection.cxx @@ -311,7 +311,7 @@ OConnection::OConnection(ODatabaseSource& _rDB { } Reference< XNameContainer > xTableDefinitions(_rDB.getTables(),UNO_QUERY); - m_pTables = new OTableContainer( *this, m_aMutex, this, bCase, xTableDefinitions, this, m_nInAppend ); + m_pTables.reset( new OTableContainer( *this, m_aMutex, this, bCase, xTableDefinitions, this, m_nInAppend ) ); // check if we supports types if ( xMeta.is() ) @@ -340,9 +340,9 @@ OConnection::OConnection(ODatabaseSource& _rDB } if(m_bSupportsViews) { - m_pViews = new OViewContainer(*this, m_aMutex, this, bCase, this, m_nInAppend); - m_pViews->addContainerListener(m_pTables); - m_pTables->addContainerListener(m_pViews); + m_pViews.reset( new OViewContainer(*this, m_aMutex, this, bCase, this, m_nInAppend) ); + m_pViews->addContainerListener(m_pTables.get()); + m_pTables->addContainerListener(m_pViews.get()); } m_bSupportsUsers = Reference< XUsersSupplier> (getMasterTables(),UNO_QUERY).is(); m_bSupportsGroups = Reference< XGroupsSupplier> (getMasterTables(),UNO_QUERY).is(); @@ -359,8 +359,6 @@ OConnection::OConnection(ODatabaseSource& _rDB OConnection::~OConnection() { - delete m_pTables; - delete m_pViews; } // XWarningsSupplier @@ -532,7 +530,7 @@ void OConnection::impl_fillTableFilter() void OConnection::refresh(const Reference< XNameAccess >& _rToBeRefreshed) { - if ( _rToBeRefreshed == Reference< XNameAccess >(m_pTables) ) + if ( _rToBeRefreshed == Reference< XNameAccess >(m_pTables.get()) ) { if (m_pTables && !m_pTables->isInitialized()) { @@ -550,7 +548,7 @@ void OConnection::refresh(const Reference< XNameAccess >& _rToBeRefreshed) } } } - else if ( _rToBeRefreshed == Reference< XNameAccess >(m_pViews) ) + else if ( _rToBeRefreshed == Reference< XNameAccess >(m_pViews.get()) ) { if (m_pViews && !m_pViews->isInitialized()) { @@ -572,9 +570,9 @@ Reference< XNameAccess > OConnection::getTables() MutexGuard aGuard(m_aMutex); checkDisposed(); - refresh(m_pTables); + refresh(m_pTables.get()); - return m_pTables; + return m_pTables.get(); } Reference< XNameAccess > SAL_CALL OConnection::getViews( ) @@ -582,9 +580,9 @@ Reference< XNameAccess > SAL_CALL OConnection::getViews( ) MutexGuard aGuard(m_aMutex); checkDisposed(); - refresh(m_pViews); + refresh(m_pViews.get()); - return m_pViews; + return m_pViews.get(); } // XQueriesSupplier diff --git a/dbaccess/source/core/dataaccess/connection.hxx b/dbaccess/source/core/dataaccess/connection.hxx index 497f03f24f24..0e548f9508d7 100644 --- a/dbaccess/source/core/dataaccess/connection.hxx +++ b/dbaccess/source/core/dataaccess/connection.hxx @@ -96,8 +96,8 @@ class OConnection final :public ::cppu::BaseMutex typedef std::map< OUString, css::uno::Reference< css::uno::XInterface> > TSupportServices; TSupportServices m_aSupportServices; - OTableContainer* m_pTables; - OViewContainer* m_pViews; + std::unique_ptr<OTableContainer> m_pTables; + std::unique_ptr<OViewContainer> m_pViews; ::dbtools::WarningsContainer m_aWarnings; std::atomic<std::size_t> m_nInAppend; bool m_bSupportsViews; // true when the getTableTypes return "VIEW" as type commit e1e1bd191a3c2d302135c574cefeeea17e2bc2ba Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Thu Mar 1 08:58:28 2018 +0200 loplugin:useuniqueptr in dbaccess Change-Id: I9b1892f3d453320302f5f82cb964aff5cd9fa643 Reviewed-on: https://gerrit.libreoffice.org/50713 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx index 1633376d7653..cf7d33f40eaa 100644 --- a/dbaccess/source/core/api/RowSet.cxx +++ b/dbaccess/source/core/api/RowSet.cxx @@ -2018,8 +2018,8 @@ void ORowSet::execute_NoApprove_NoNewConn(ResettableMutexGuard& _rClearForNotifi else { Reference<XDatabaseMetaData> xMeta = m_xActiveConnection->getMetaData(); - m_pColumns = new ORowSetDataColumns(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers(), - aColumns,*this,m_aColumnsMutex,aNames); + m_pColumns.reset( new ORowSetDataColumns(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers(), + aColumns,*this,m_aColumnsMutex,aNames) ); } } else // !m_bCommandFacetsDirty @@ -2837,8 +2837,8 @@ ORowSetClone::ORowSetClone( const Reference<XComponentContext>& _rContext, ORowS } } Reference<XDatabaseMetaData> xMeta = rParent.m_xActiveConnection->getMetaData(); - m_pColumns = new ORowSetDataColumns(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers(), - aColumns,*this,m_aMutex,aNames); + m_pColumns.reset( new ORowSetDataColumns(xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers(), + aColumns,*this,m_aMutex,aNames) ); sal_Int32 const nRT = PropertyAttribute::READONLY | PropertyAttribute::TRANSIENT; diff --git a/dbaccess/source/core/api/RowSetBase.cxx b/dbaccess/source/core/api/RowSetBase.cxx index f7717bc77fa7..454ee93cab74 100644 --- a/dbaccess/source/core/api/RowSetBase.cxx +++ b/dbaccess/source/core/api/RowSetBase.cxx @@ -107,11 +107,7 @@ ORowSetBase::~ORowSetBase() TDataColumns().swap(m_aDataColumns); m_pColumns->acquire(); m_pColumns->disposing(); - delete m_pColumns; - m_pColumns = nullptr; } - - delete m_pEmptyCollection; } // css::lang::XTypeProvider @@ -551,11 +547,11 @@ Reference< XNameAccess > SAL_CALL ORowSetBase::getColumns( ) if(!m_pColumns) { if (!m_pEmptyCollection) - m_pEmptyCollection = new OEmptyCollection(*m_pMySelf,m_aColumnsMutex); - return m_pEmptyCollection; + m_pEmptyCollection.reset( new OEmptyCollection(*m_pMySelf,m_aColumnsMutex) ); + return m_pEmptyCollection.get(); } - return m_pColumns; + return m_pColumns.get(); } // XResultSet diff --git a/dbaccess/source/core/api/RowSetBase.hxx b/dbaccess/source/core/api/RowSetBase.hxx index cb2a04561349..339b5dfc9e14 100644 --- a/dbaccess/source/core/api/RowSetBase.hxx +++ b/dbaccess/source/core/api/RowSetBase.hxx @@ -88,11 +88,11 @@ namespace dbaccess ::cppu::OWeakObject* m_pMySelf; // set by derived classes ORowSetCache* m_pCache; // the cache is used by the rowset and his clone (shared) - ORowSetDataColumns* m_pColumns; // represent the select columns + std::unique_ptr<ORowSetDataColumns> m_pColumns; // represent the select columns ::cppu::OBroadcastHelper& m_rBHelper; // must be set from the derived classes // is used when the formatkey for database types is set css::uno::Reference< css::util::XNumberFormatTypes> m_xNumberFormatTypes; - OEmptyCollection* m_pEmptyCollection; + std::unique_ptr<OEmptyCollection> m_pEmptyCollection; css::uno::Reference< css::uno::XComponentContext> m_aContext; ::connectivity::SQLError m_aErrors; diff --git a/dbaccess/source/core/api/preparedstatement.cxx b/dbaccess/source/core/api/preparedstatement.cxx index 74a8edbf1cd8..10fb3e4cc065 100644 --- a/dbaccess/source/core/api/preparedstatement.cxx +++ b/dbaccess/source/core/api/preparedstatement.cxx @@ -52,15 +52,13 @@ OPreparedStatement::OPreparedStatement(const Reference< XConnection > & _xConn, m_xAggregateAsParameters.set( m_xAggregateAsSet, UNO_QUERY_THROW ); Reference<XDatabaseMetaData> xMeta = _xConn->getMetaData(); - m_pColumns = new OColumns(*this, m_aMutex, xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers(),std::vector< OUString>(), nullptr,nullptr); + m_pColumns.reset( new OColumns(*this, m_aMutex, xMeta.is() && xMeta->supportsMixedCaseQuotedIdentifiers(),std::vector< OUString>(), nullptr,nullptr) ); } OPreparedStatement::~OPreparedStatement() { m_pColumns->acquire(); m_pColumns->disposing(); - delete m_pColumns; - } // css::lang::XTypeProvider @@ -169,7 +167,7 @@ Reference< css::container::XNameAccess > OPreparedStatement::getColumns() } m_pColumns->setInitialized(); } - return m_pColumns; + return m_pColumns.get(); } // XResultSetMetaDataSupplier diff --git a/dbaccess/source/core/api/resultset.cxx b/dbaccess/source/core/api/resultset.cxx index d172a3bdf804..6b87e69c55a1 100644 --- a/dbaccess/source/core/api/resultset.cxx +++ b/dbaccess/source/core/api/resultset.cxx @@ -61,7 +61,7 @@ OResultSet::OResultSet(const css::uno::Reference< css::sdbc::XResultSet >& _xRes ,m_nResultSetConcurrency(0) ,m_bIsBookmarkable(false) { - m_pColumns = new OColumns(*this, m_aMutex, _bCaseSensitive, std::vector< OUString>(), nullptr,nullptr); + m_pColumns.reset( new OColumns(*this, m_aMutex, _bCaseSensitive, std::vector< OUString>(), nullptr,nullptr) ); try { @@ -96,8 +96,6 @@ OResultSet::~OResultSet() { m_pColumns->acquire(); m_pColumns->disposing(); - delete m_pColumns; - } // css::lang::XTypeProvider @@ -346,7 +344,7 @@ Reference< css::container::XNameAccess > OResultSet::getColumns() // are allowed to return duplicate names, but we are required to have // unique column names if ( m_pColumns->hasByName( sName ) ) - sName = ::dbtools::createUniqueName( m_pColumns, sName ); + sName = ::dbtools::createUniqueName( m_pColumns.get(), sName ); m_pColumns->append( sName, pColumn ); } @@ -362,7 +360,7 @@ Reference< css::container::XNameAccess > OResultSet::getColumns() // this might be reasonable try { - const Reference< XNameAccess > xColNames( static_cast< XNameAccess* >( m_pColumns ), UNO_SET_THROW ); + const Reference< XNameAccess > xColNames( static_cast< XNameAccess* >( m_pColumns.get() ), UNO_SET_THROW ); const Sequence< OUString > aNames( xColNames->getElementNames() ); SAL_WARN_IF( aNames.getLength() != nColCount, "dbaccess", "OResultSet::getColumns: invalid column count!" ); @@ -381,7 +379,7 @@ Reference< css::container::XNameAccess > OResultSet::getColumns() } #endif } - return m_pColumns; + return m_pColumns.get(); } // css::sdbc::XRow diff --git a/dbaccess/source/core/api/resultset.hxx b/dbaccess/source/core/api/resultset.hxx index 9d498584c012..574b458bf986 100644 --- a/dbaccess/source/core/api/resultset.hxx +++ b/dbaccess/source/core/api/resultset.hxx @@ -71,7 +71,7 @@ namespace dbaccess css::uno::Reference< css::sdbc::XRowUpdate > m_xDelegatorRowUpdate; ::dbtools::WarningsContainer m_aWarnings; - OColumns* m_pColumns; + std::unique_ptr<OColumns> m_pColumns; sal_Int32 m_nResultSetType; sal_Int32 m_nResultSetConcurrency; bool m_bIsBookmarkable : 1; diff --git a/dbaccess/source/core/dataaccess/intercept.cxx b/dbaccess/source/core/dataaccess/intercept.cxx index de566166743e..6a0bc7b18485 100644 --- a/dbaccess/source/core/dataaccess/intercept.cxx +++ b/dbaccess/source/core/dataaccess/intercept.cxx @@ -93,8 +93,6 @@ OInterceptor::OInterceptor( ODocumentDefinition* _pContentHolder ) OInterceptor::~OInterceptor() { - delete m_pDisposeEventListeners; - delete m_pStatCL; } struct DispatchHelper @@ -220,7 +218,7 @@ void SAL_CALL OInterceptor::addStatusListener( { osl::MutexGuard aGuard(m_aMutex); if(!m_pStatCL) - m_pStatCL = new PropertyChangeListenerContainer(m_aMutex); + m_pStatCL.reset( new PropertyChangeListenerContainer(m_aMutex) ); } m_pStatCL->addInterface(URL.Complete,Control); @@ -237,7 +235,7 @@ void SAL_CALL OInterceptor::addStatusListener( { osl::MutexGuard aGuard(m_aMutex); if(!m_pStatCL) - m_pStatCL = new PropertyChangeListenerContainer(m_aMutex); + m_pStatCL.reset( new PropertyChangeListenerContainer(m_aMutex) ); } m_pStatCL->addInterface(URL.Complete,Control); @@ -261,7 +259,7 @@ void SAL_CALL OInterceptor::addStatusListener( { osl::MutexGuard aGuard(m_aMutex); if(!m_pStatCL) - m_pStatCL = new PropertyChangeListenerContainer(m_aMutex); + m_pStatCL.reset( new PropertyChangeListenerContainer(m_aMutex) ); } m_pStatCL->addInterface(URL.Complete,Control); diff --git a/dbaccess/source/core/dataaccess/intercept.hxx b/dbaccess/source/core/dataaccess/intercept.hxx index cfb83676f5ab..bcce278492bb 100644 --- a/dbaccess/source/core/dataaccess/intercept.hxx +++ b/dbaccess/source/core/dataaccess/intercept.hxx @@ -104,8 +104,8 @@ private: css::uno::Sequence< OUString > m_aInterceptedURL; - comphelper::OInterfaceContainerHelper2* m_pDisposeEventListeners; - PropertyChangeListenerContainer* m_pStatCL; + std::unique_ptr<comphelper::OInterfaceContainerHelper2> m_pDisposeEventListeners; + std::unique_ptr<PropertyChangeListenerContainer> m_pStatCL; }; } // namespace dbaccess diff --git a/dbaccess/source/core/inc/preparedstatement.hxx b/dbaccess/source/core/inc/preparedstatement.hxx index bfd0e26ea6fd..eb5b6a5f5dc5 100644 --- a/dbaccess/source/core/inc/preparedstatement.hxx +++ b/dbaccess/source/core/inc/preparedstatement.hxx @@ -40,7 +40,7 @@ namespace dbaccess public css::lang::XServiceInfo { protected: - OColumns* m_pColumns; + std::unique_ptr<OColumns> m_pColumns; css::uno::Reference< css::sdbc::XParameters > m_xAggregateAsParameters; public: _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits