diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-20 13:18:44 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-23 07:56:34 +0200 |
commit | b395d9fd82cbc551d561c7a7ffe1751f5a35e339 (patch) | |
tree | 02c947ea540b90ae4ab96a36cd270b118e8b0497 /connectivity | |
parent | 017911facd7bf66bd8743e1d3357c2808dcd1bba (diff) |
use rtl::Reference in OResultSet
instead of manual acquire/release
Change-Id: I8baa2e7ac64445ea69d4b62566a89b6e42307e51
Diffstat (limited to 'connectivity')
-rw-r--r-- | connectivity/source/drivers/mork/MResultSet.cxx | 25 | ||||
-rw-r--r-- | connectivity/source/drivers/mork/MResultSet.hxx | 3 |
2 files changed, 11 insertions, 17 deletions
diff --git a/connectivity/source/drivers/mork/MResultSet.cxx b/connectivity/source/drivers/mork/MResultSet.cxx index 50e5b4794f63..7ce0643280ca 100644 --- a/connectivity/source/drivers/mork/MResultSet.cxx +++ b/connectivity/source/drivers/mork/MResultSet.cxx @@ -78,7 +78,6 @@ OResultSet::OResultSet(OCommonStatement* pStmt, const std::shared_ptr< connectiv ,m_pSQLIterator( _pSQLIterator ) ,m_pParseTree( _pSQLIterator->getParseTree() ) ,m_aQueryHelper(pStmt->getOwnConnection()->getColumnAlias()) - ,m_pTable(nullptr) ,m_CurrentRowCount(0) ,m_nParamIndex(0) ,m_bIsAlwaysFalseQuery(false) @@ -106,11 +105,7 @@ void OResultSet::disposing() m_xColumns = nullptr; m_xParamColumns = nullptr; m_pKeySet = nullptr; - if(m_pTable) - { - m_pTable->release(); - m_pTable = nullptr; - } + m_xTable.clear(); } Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeException, std::exception) @@ -133,7 +128,7 @@ Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeExcep void OResultSet::methodEntry() { checkDisposed(OResultSet_BASE::rBHelper.bDisposed); - if ( !m_pTable ) + if ( !m_xTable.is() ) { OSL_FAIL( "OResultSet::methodEntry: looks like we're disposed, but how is this possible?" ); throw DisposedException( OUString(), *this ); @@ -244,7 +239,7 @@ Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData( ) throw(SQLEx if(!m_xMetaData.is()) m_xMetaData = new OResultSetMetaData( - m_pSQLIterator->getSelectColumns(), m_pSQLIterator->getTables().begin()->first ,m_pTable,determineReadOnly()); + m_pSQLIterator->getSelectColumns(), m_pSQLIterator->getTables().begin()->first, m_xTable.get(), determineReadOnly()); return m_xMetaData; } @@ -1001,7 +996,7 @@ void OResultSet::fillRowData() return; } - OUString aStr( m_pTable->getName() ); + OUString aStr( m_xTable->getName() ); m_aQueryHelper.setAddressbook( aStr ); sal_Int32 rv = m_aQueryHelper.executeQuery(pConnection, queryExpression); @@ -1068,15 +1063,14 @@ void SAL_CALL OResultSet::executeQuery() throw(css::sdbc::SQLException, { ResultSetEntryGuard aGuard( *this ); - OSL_ENSURE( m_pTable, "Need a Table object"); - if(!m_pTable) + OSL_ENSURE( m_xTable.is(), "Need a Table object"); + if(!m_xTable.is()) { const OSQLTables& rTabs = m_pSQLIterator->getTables(); if (rTabs.empty() || !rTabs.begin()->second.is()) m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this ); - m_pTable = static_cast< OTable* > ((rTabs.begin()->second).get()); - + m_xTable = static_cast< OTable* > ((rTabs.begin()->second).get()); } m_nRowPos = 0; @@ -1752,9 +1746,8 @@ bool OResultSet::determineReadOnly() void OResultSet::setTable(OTable* _rTable) { - m_pTable = _rTable; - m_pTable->acquire(); - m_xTableColumns = m_pTable->getColumns(); + m_xTable = _rTable; + m_xTableColumns = m_xTable->getColumns(); if(m_xTableColumns.is()) m_aColumnNames = m_xTableColumns->getElementNames(); } diff --git a/connectivity/source/drivers/mork/MResultSet.hxx b/connectivity/source/drivers/mork/MResultSet.hxx index a05b1b65dddc..081352aba80a 100644 --- a/connectivity/source/drivers/mork/MResultSet.hxx +++ b/connectivity/source/drivers/mork/MResultSet.hxx @@ -34,6 +34,7 @@ #include <cppuhelper/compbase.hxx> #include <comphelper/proparrhlp.hxx> #include <tools/gen.hxx> +#include <rtl/ref.hxx> #include "MStatement.hxx" #include "MQueryHelper.hxx" #include <connectivity/CommonTools.hxx> @@ -215,7 +216,7 @@ namespace connectivity protected: //MQuery m_aQuery; MQueryHelper m_aQueryHelper; - OTable* m_pTable; + rtl::Reference<OTable> m_xTable; sal_Int32 m_CurrentRowCount; css::uno::Reference< css::container::XNameAccess > m_xTableColumns; |