diff options
author | Noel Grandin <noel@peralex.com> | 2016-05-23 13:53:42 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-05-24 06:54:06 +0000 |
commit | 111de438ea3e512a541281dc0716cc728ea8d152 (patch) | |
tree | 2c9ca866e79ed0cfc9299e553a87239345c515a6 /connectivity | |
parent | d3f21849ec8580fdb59a1f0b35453657f4050e0f (diff) |
remove some manual ref-counting
triggered when I noticed a class doing acquire() in the constructor and
then release() in the destructor.
found mostly by
git grep -n -B5 -e '->release()'
Change-Id: Ie1abeaed75c1f861df185e3bde680272dbadc97f
Reviewed-on: https://gerrit.libreoffice.org/25363
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/dbase/DIndexIter.cxx | 19 | ||||
-rw-r--r-- | connectivity/source/drivers/mork/MConnection.cxx | 7 | ||||
-rw-r--r-- | connectivity/source/drivers/mork/MConnection.hxx | 4 | ||||
-rw-r--r-- | connectivity/source/drivers/postgresql/pq_connection.cxx | 10 | ||||
-rw-r--r-- | connectivity/source/inc/dbase/DIndexIter.hxx | 5 |
5 files changed, 18 insertions, 27 deletions
diff --git a/connectivity/source/drivers/dbase/DIndexIter.cxx b/connectivity/source/drivers/dbase/DIndexIter.cxx index 3c0318b4c36f..3f072f8172d1 100644 --- a/connectivity/source/drivers/dbase/DIndexIter.cxx +++ b/connectivity/source/drivers/dbase/DIndexIter.cxx @@ -30,7 +30,6 @@ using namespace connectivity::file; OIndexIterator::~OIndexIterator() { - m_pIndex->release(); } @@ -51,7 +50,7 @@ sal_uInt32 OIndexIterator::Find(bool bFirst) if (bFirst) { - m_aRoot = m_pIndex->getRoot(); + m_aRoot = m_xIndex->getRoot(); m_aCurLeaf.Clear(); } @@ -62,7 +61,7 @@ sal_uInt32 OIndexIterator::Find(bool bFirst) { ONDXPage* pPage = m_aRoot; while (pPage && !pPage->IsLeaf()) - pPage = pPage->GetChild(m_pIndex); + pPage = pPage->GetChild(m_xIndex.get()); m_aCurLeaf = pPage; m_nCurNode = NODE_NOTFOUND; @@ -108,8 +107,8 @@ ONDXKey* OIndexIterator::GetFirstKey(ONDXPage* pPage, const OOperand& rKey) if (!pPage->IsLeaf()) { // descend further - ONDXPagePtr aPage = (i==0) ? pPage->GetChild(m_pIndex) - : ((*pPage)[i-1]).GetChild(m_pIndex, pPage); + ONDXPagePtr aPage = (i==0) ? pPage->GetChild(m_xIndex.get()) + : ((*pPage)[i-1]).GetChild(m_xIndex.get(), pPage); pFoundKey = aPage.Is() ? GetFirstKey(aPage, rKey) : nullptr; } else if (i == pPage->Count()) @@ -144,7 +143,7 @@ sal_uInt32 OIndexIterator::GetCompare(bool bFirst) case SQLFilterOperator::LESS: case SQLFilterOperator::LESS_EQUAL: while (pPage && !pPage->IsLeaf()) - pPage = pPage->GetChild(m_pIndex); + pPage = pPage->GetChild(m_xIndex.get()); m_aCurLeaf = pPage; m_nCurNode = NODE_NOTFOUND; @@ -206,7 +205,7 @@ sal_uInt32 OIndexIterator::GetLike(bool bFirst) ONDXPage* pPage = m_aRoot; while (pPage && !pPage->IsLeaf()) - pPage = pPage->GetChild(m_pIndex); + pPage = pPage->GetChild(m_xIndex.get()); m_aCurLeaf = pPage; m_nCurNode = NODE_NOTFOUND; @@ -225,7 +224,7 @@ sal_uInt32 OIndexIterator::GetNull(bool bFirst) { ONDXPage* pPage = m_aRoot; while (pPage && !pPage->IsLeaf()) - pPage = pPage->GetChild(m_pIndex); + pPage = pPage->GetChild(m_xIndex.get()); m_aCurLeaf = pPage; m_nCurNode = NODE_NOTFOUND; @@ -274,7 +273,7 @@ ONDXKey* OIndexIterator::GetNextKey() sal_uInt16 nPos = pParentPage->Search(pPage); if (nPos != pParentPage->Count() - 1) { // page found - pPage = (*pParentPage)[nPos+1].GetChild(m_pIndex,pParentPage); + pPage = (*pParentPage)[nPos+1].GetChild(m_xIndex.get(),pParentPage); break; } } @@ -283,7 +282,7 @@ ONDXKey* OIndexIterator::GetNextKey() // now go on with leaf while (pPage && !pPage->IsLeaf()) - pPage = pPage->GetChild(m_pIndex); + pPage = pPage->GetChild(m_xIndex.get()); m_aCurLeaf = pPage; m_nCurNode = 0; diff --git a/connectivity/source/drivers/mork/MConnection.cxx b/connectivity/source/drivers/mork/MConnection.cxx index 633f84e3011f..84722b594564 100644 --- a/connectivity/source/drivers/mork/MConnection.cxx +++ b/connectivity/source/drivers/mork/MConnection.cxx @@ -40,10 +40,9 @@ static const int defaultScope = 0x80; OConnection::OConnection(MorkDriver* _pDriver) :OSubComponent<OConnection, OConnection_BASE>(static_cast<cppu::OWeakObject*>(_pDriver), this) - ,m_pDriver(_pDriver) + ,m_xDriver(_pDriver) ,m_aColumnAlias( _pDriver->getFactory() ) { - m_pDriver->acquire(); m_pBook = new MorkParser(); m_pHistory = new MorkParser(); } @@ -52,8 +51,6 @@ OConnection::~OConnection() { if(!isClosed()) close(); - m_pDriver->release(); - m_pDriver = nullptr; delete m_pBook; delete m_pHistory; } @@ -112,7 +109,7 @@ void OConnection::construct(const OUString& url,const Sequence< PropertyValue >& // production? if (unittestIndex == -1) { - OUString path = m_pDriver->getProfilePath(); + OUString path = m_xDriver->getProfilePath(); SAL_INFO("connectivity.mork", "ProfilePath: " << path); abook = path + "/abook.mab"; history = path + "/history.mab"; diff --git a/connectivity/source/drivers/mork/MConnection.hxx b/connectivity/source/drivers/mork/MConnection.hxx index 3654b6926085..e573d057aafd 100644 --- a/connectivity/source/drivers/mork/MConnection.hxx +++ b/connectivity/source/drivers/mork/MConnection.hxx @@ -37,7 +37,7 @@ namespace connectivity // Data attributes - MorkDriver* m_pDriver; // Pointer to the owning + css::uno::Reference<MorkDriver> m_xDriver; // Pointer to the owning // driver object OColumnAlias m_aColumnAlias; // Mork Parser (abook) @@ -52,7 +52,7 @@ namespace connectivity explicit OConnection(MorkDriver* const driver); virtual ~OConnection(); - MorkDriver* getDriver() {return m_pDriver;}; + const css::uno::Reference<MorkDriver>& getDriver() {return m_xDriver;}; MorkParser* getMorkParser(const OString& t) {return t == "CollectedAddressBook" ? m_pHistory : m_pBook;}; // OComponentHelper diff --git a/connectivity/source/drivers/postgresql/pq_connection.cxx b/connectivity/source/drivers/postgresql/pq_connection.cxx index ebe1aaac52f2..214f08c47b7d 100644 --- a/connectivity/source/drivers/postgresql/pq_connection.cxx +++ b/connectivity/source/drivers/postgresql/pq_connection.cxx @@ -96,28 +96,24 @@ namespace pq_sdbc_driver // Helper class for statement lifetime management class ClosableReference : public cppu::WeakImplHelper< com::sun::star::uno::XReference > { - Connection *m_conn; + css::uno::Reference<Connection> m_conn; ::rtl::ByteSequence m_id; public: ClosableReference( const ::rtl::ByteSequence & id , Connection *that ) : m_conn( that ), m_id( id ) { - that->acquire(); } virtual ~ClosableReference() { - if( m_conn ) - m_conn->release(); } virtual void SAL_CALL dispose() throw (std::exception) override { - if( m_conn ) + if( m_conn.is() ) { m_conn->removeFromWeakMap(m_id); - m_conn->release(); - m_conn = nullptr; + m_conn.clear(); } } }; diff --git a/connectivity/source/inc/dbase/DIndexIter.hxx b/connectivity/source/inc/dbase/DIndexIter.hxx index 0b70f96e0c25..7b950fdd0923 100644 --- a/connectivity/source/inc/dbase/DIndexIter.hxx +++ b/connectivity/source/inc/dbase/DIndexIter.hxx @@ -36,7 +36,7 @@ namespace connectivity protected: file::OBoolOperator* m_pOperator; const file::OOperand* m_pOperand; - ODbaseIndex* m_pIndex; + css::uno::Reference<ODbaseIndex> m_xIndex; ONDXPagePtr m_aRoot, m_aCurLeaf; sal_uInt16 m_nCurNode; @@ -57,10 +57,9 @@ namespace connectivity const file::OOperand* pOper) :m_pOperator(pOp) ,m_pOperand(pOper) - ,m_pIndex(pInd) + ,m_xIndex(pInd) ,m_nCurNode(NODE_NOTFOUND) { - pInd->acquire(); } virtual ~OIndexIterator(); |