Kaydet (Commit) aaebe3c4 authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Noel Grandin

remove some manual ref-counting in connectivity

Change-Id: I0d00b4566c13817b296f237e993f4ce63ef0c664
Reviewed-on: https://gerrit.libreoffice.org/26053Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst a7415828
......@@ -34,10 +34,7 @@ namespace connectivity
:m_pConnectionPool(_pPool)
{
OSL_ENSURE(_rxAggregateDriver.is(), "ODriverWrapper::ODriverWrapper: invalid aggregate!");
OSL_ENSURE(m_pConnectionPool, "ODriverWrapper::ODriverWrapper: invalid connection pool!");
if (m_pConnectionPool)
m_pConnectionPool->acquire();
OSL_ENSURE(m_pConnectionPool.is(), "ODriverWrapper::ODriverWrapper: invalid connection pool!");
osl_atomic_increment( &m_refCount );
if (_rxAggregateDriver.is())
......@@ -61,10 +58,6 @@ namespace connectivity
{
if (m_xDriverAggregate.is())
m_xDriverAggregate->setDelegator(nullptr);
if (m_pConnectionPool)
m_pConnectionPool->release();
m_pConnectionPool = nullptr;
}
......@@ -78,7 +71,7 @@ namespace connectivity
Reference< XConnection > SAL_CALL ODriverWrapper::connect( const OUString& url, const Sequence< PropertyValue >& info ) throw (SQLException, RuntimeException, std::exception)
{
Reference< XConnection > xConnection;
if (m_pConnectionPool)
if (m_pConnectionPool.is())
// route this through the pool
xConnection = m_pConnectionPool->getConnectionWithInfo( url, info );
else if (m_xDriver.is())
......
......@@ -23,6 +23,7 @@
#include <com/sun/star/sdbc/XDriver.hpp>
#include <cppuhelper/implbase.hxx>
#include <osl/mutex.hxx>
#include <rtl/ref.hxx>
#include <com/sun/star/uno/XAggregation.hpp>
......@@ -41,7 +42,8 @@ namespace connectivity
m_xDriverAggregate;
css::uno::Reference< css::sdbc::XDriver >
m_xDriver;
OConnectionPool* m_pConnectionPool;
rtl::Reference<OConnectionPool>
m_pConnectionPool;
public:
/** creates a new wrapper for a driver
......
......@@ -284,11 +284,9 @@ void OPoolCollection::clearConnectionPools(bool _bDispose)
while(aIter != m_aPools.end())
{
aIter->second->clear(_bDispose);
aIter->second->release();
OUString sKeyValue = aIter->first;
++aIter;
m_aPools.erase(sKeyValue);
}
m_aPools.clear();
}
OConnectionPool* OPoolCollection::getConnectionPool(const OUString& _sImplName,
......@@ -298,16 +296,15 @@ OConnectionPool* OPoolCollection::getConnectionPool(const OUString& _sImplName,
OConnectionPool *pRet = nullptr;
OConnectionPools::const_iterator aFind = m_aPools.find(_sImplName);
if (aFind != m_aPools.end())
pRet = aFind->second;
pRet = aFind->second.get();
else if (_xDriver.is() && _xDriverNode.is())
{
Reference<XPropertySet> xProp(_xDriverNode,UNO_QUERY);
if(xProp.is())
xProp->addPropertyChangeListener(getEnableNodeName(),this);
OConnectionPool* pConnectionPool = new OConnectionPool(_xDriver,_xDriverNode,m_xProxyFactory);
pConnectionPool->acquire();
aFind = m_aPools.insert(OConnectionPools::value_type(_sImplName,pConnectionPool)).first;
pRet = aFind->second;
pRet = aFind->second.get();
}
OSL_ENSURE(pRet, "Could not query DriverManager from ConnectionPool!");
......@@ -456,10 +453,8 @@ void SAL_CALL OPoolCollection::propertyChange( const css::beans::PropertyChangeE
for(;aIter != m_aPools.end();++aIter)
{
aIter->second->clear(false);
aIter->second->release();
}
m_aPools.clear();
m_aPools = OConnectionPools();
}
}
else if(evt.Source.is())
......@@ -484,10 +479,9 @@ void SAL_CALL OPoolCollection::propertyChange( const css::beans::PropertyChangeE
// 2nd clear the connectionpool
OConnectionPools::iterator aFind = m_aPools.find(sThisDriverName);
if(aFind != m_aPools.end() && aFind->second)
if(aFind != m_aPools.end())
{
aFind->second->clear(false);
aFind->second->release();
m_aPools.erase(aFind);
}
}
......
......@@ -39,6 +39,7 @@
#include <com/sun/star/reflection/XProxyFactory.hpp>
#include <comphelper/stl_types.hxx>
#include <osl/mutex.hxx>
#include <rtl/ref.hxx>
namespace connectivity
{
......@@ -59,7 +60,7 @@ namespace connectivity
typedef ::comphelper::OInterfaceCompare< css::sdbc::XDriver > ODriverCompare;
typedef std::map<OUString, OConnectionPool*> OConnectionPools;
typedef std::map<OUString, rtl::Reference<OConnectionPool>> OConnectionPools;
typedef std::map<
css::uno::Reference< css::sdbc::XDriver >,
......
......@@ -94,14 +94,14 @@ sal_Bool SAL_CALL ODbaseResultSet::moveToBookmark( const Any& bookmark ) throw(
m_bRowDeleted = m_bRowInserted = m_bRowUpdated = false;
return m_pTable && Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),true);
return m_pTable.is() && Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),true);
}
sal_Bool SAL_CALL ODbaseResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw( SQLException, RuntimeException, std::exception)
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
if(!m_pTable)
if(!m_pTable.is())
return false;
......
......@@ -134,8 +134,8 @@ Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData( ) thr
if(!m_xMetaData.is())
m_xMetaData = new OResultSetMetaData(m_aSQLIterator.getSelectColumns(),m_aSQLIterator.getTables().begin()->first,m_pTable);
return m_xMetaData;
m_xMetaData = new OResultSetMetaData(m_aSQLIterator.getSelectColumns(),m_aSQLIterator.getTables().begin()->first,m_pTable.get());
return m_xMetaData.get();
}
......@@ -191,7 +191,7 @@ Reference< XConnection > SAL_CALL OPreparedStatement::getConnection( ) throw(SQ
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
return Reference< XConnection >(m_pConnection);
return Reference< XConnection >(m_pConnection.get());
}
......
......@@ -80,7 +80,6 @@ OResultSet::OResultSet(OStatement_Base* pStmt,OSQLParseTreeIterator& _aSQLIte
,m_aSkipDeletedSet(this)
,m_pFileSet(nullptr)
,m_pSortIndex(nullptr)
,m_pTable(nullptr)
,m_pParseTree(pStmt->getParseTree())
,m_pSQLAnalyzer(nullptr)
,m_aSQLIterator(_aSQLIterator)
......@@ -147,14 +146,10 @@ void OResultSet::disposing()
m_xParamColumns = nullptr;
m_xColsIdx.clear();
Reference<XComponent> xComp = m_pTable;
Reference<XComponent> xComp = m_pTable.get();
if ( xComp.is() )
xComp->removeEventListener(this);
if(m_pTable)
{
m_pTable->release();
m_pTable = nullptr;
}
m_pTable.clear();
m_pFileSet = nullptr;
DELETEZ(m_pSortIndex);
......@@ -301,7 +296,7 @@ Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData( ) throw(SQLEx
if(!m_xMetaData.is())
m_xMetaData = new OResultSetMetaData(m_xColumns,m_aSQLIterator.getTables().begin()->first,m_pTable);
m_xMetaData = new OResultSetMetaData(m_xColumns,m_aSQLIterator.getTables().begin()->first,m_pTable.get());
return m_xMetaData;
}
......@@ -414,7 +409,7 @@ sal_Bool SAL_CALL OResultSet::first( ) throw(SQLException, RuntimeException, st
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
return m_pTable && m_aSkipDeletedSet.skipDeleted(IResultSetHelper::FIRST,1,true);
return m_pTable.is() && m_aSkipDeletedSet.skipDeleted(IResultSetHelper::FIRST,1,true);
}
......@@ -423,28 +418,28 @@ sal_Bool SAL_CALL OResultSet::last( ) throw(SQLException, RuntimeException, std
// here I know definitely that I stand on the last record
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
return m_pTable && m_aSkipDeletedSet.skipDeleted(IResultSetHelper::LAST,1,true);
return m_pTable.is() && m_aSkipDeletedSet.skipDeleted(IResultSetHelper::LAST,1,true);
}
sal_Bool SAL_CALL OResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException, std::exception)
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
return m_pTable && m_aSkipDeletedSet.skipDeleted(IResultSetHelper::ABSOLUTE1,row,true);
return m_pTable.is() && m_aSkipDeletedSet.skipDeleted(IResultSetHelper::ABSOLUTE1,row,true);
}
sal_Bool SAL_CALL OResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException, std::exception)
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
return m_pTable && m_aSkipDeletedSet.skipDeleted(IResultSetHelper::RELATIVE1,row,true);
return m_pTable.is() && m_aSkipDeletedSet.skipDeleted(IResultSetHelper::RELATIVE1,row,true);
}
sal_Bool SAL_CALL OResultSet::previous( ) throw(SQLException, RuntimeException, std::exception)
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
return m_pTable && m_aSkipDeletedSet.skipDeleted(IResultSetHelper::PRIOR,0,true);
return m_pTable.is() && m_aSkipDeletedSet.skipDeleted(IResultSetHelper::PRIOR,0,true);
}
Reference< XInterface > SAL_CALL OResultSet::getStatement( ) throw(SQLException, RuntimeException, std::exception)
......@@ -498,7 +493,7 @@ sal_Bool SAL_CALL OResultSet::next( ) throw(SQLException, RuntimeException, std
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
return m_pTable && m_aSkipDeletedSet.skipDeleted(IResultSetHelper::NEXT,1,true);
return m_pTable.is() && m_aSkipDeletedSet.skipDeleted(IResultSetHelper::NEXT,1,true);
}
......@@ -530,7 +525,7 @@ void SAL_CALL OResultSet::insertRow( ) throw(SQLException, RuntimeException, st
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
if(!m_bInserted || !m_pTable)
if(!m_bInserted || !m_pTable.is())
throwFunctionSequenceException(*this);
// we know that we append new rows at the end
......@@ -553,7 +548,7 @@ void SAL_CALL OResultSet::updateRow( ) throw(SQLException, RuntimeException, st
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
if(!m_pTable || m_pTable->isReadOnly())
if(!m_pTable.is() || m_pTable->isReadOnly())
lcl_throwError(STR_TABLE_READONLY,*this);
m_bRowUpdated = m_pTable->UpdateRow(*m_aInsertRow, m_aRow,m_xColsIdx);
......@@ -567,8 +562,7 @@ void SAL_CALL OResultSet::deleteRow() throw(SQLException, RuntimeException, std:
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
if(!m_pTable || m_pTable->isReadOnly())
if(!m_pTable.is() || m_pTable->isReadOnly())
lcl_throwError(STR_TABLE_READONLY,*this);
if (m_bShowDeleted)
lcl_throwError(STR_DELETE_ROW,*this);
......@@ -613,7 +607,7 @@ void SAL_CALL OResultSet::moveToInsertRow( ) throw(SQLException, RuntimeExcepti
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
if(!m_pTable || m_pTable->isReadOnly())
if(!m_pTable.is() || m_pTable->isReadOnly())
lcl_throwError(STR_TABLE_READONLY,*this);
m_bInserted = true;
......@@ -777,7 +771,7 @@ bool OResultSet::ExecuteRow(IResultSetHelper::Movement eFirstCursorPosition,
IResultSetHelper::Movement eCursorPosition = eFirstCursorPosition;
sal_Int32 nOffset = nFirstOffset;
if (!m_pTable)
if (!m_pTable.is())
return false;
const OSQLColumns & rTableCols = *(m_pTable->getTableColumns());
......@@ -791,7 +785,7 @@ again:
return false;
}
if (!m_pTable || !m_pTable->seekRow(eCursorPosition, nOffset, m_nFilePos))
if (!m_pTable.is() || !m_pTable->seekRow(eCursorPosition, nOffset, m_nFilePos))
{
return false;
}
......@@ -1180,7 +1174,7 @@ void OResultSet::sortRows()
bool OResultSet::OpenImpl()
{
OSL_ENSURE(m_pSQLAnalyzer,"No analyzer set with setSqlAnalyzer!");
if(!m_pTable)
if(!m_pTable.is())
{
const OSQLTables& rTabs = m_aSQLIterator.getTables();
if (rTabs.empty() || !rTabs.begin()->second.is())
......@@ -1570,8 +1564,7 @@ void OResultSet::doTableSpecials(const OSQLTable& _xTable)
{
Reference<css::lang::XUnoTunnel> xTunnel(_xTable, UNO_QUERY_THROW);
m_pTable = reinterpret_cast< OFileTable* >(xTunnel->getSomething(OFileTable::getUnoTunnelImplementationId()));
assert(m_pTable);
m_pTable->acquire();
assert(m_pTable.is());
}
void OResultSet::clearInsertRow()
......@@ -1624,11 +1617,10 @@ bool OResultSet::isRowDeleted() const
void SAL_CALL OResultSet::disposing( const EventObject& Source ) throw (RuntimeException, std::exception)
{
Reference<XPropertySet> xProp = m_pTable;
if(m_pTable && Source.Source == xProp)
Reference<XPropertySet> xProp = m_pTable.get();
if(m_pTable.is() && Source.Source == xProp)
{
m_pTable->release();
m_pTable = nullptr;
m_pTable.clear();
}
}
......
......@@ -60,7 +60,6 @@ OStatement_Base::OStatement_Base(OConnection* _pConnection )
,m_pConnection(_pConnection)
,m_pParseTree(nullptr)
,m_pSQLAnalyzer(nullptr)
,m_pTable(nullptr)
,m_nMaxFieldSize(0)
,m_nMaxRows(0)
,m_nQueryTimeOut(0)
......@@ -70,8 +69,6 @@ OStatement_Base::OStatement_Base(OConnection* _pConnection )
,m_nResultSetConcurrency(ResultSetConcurrency::UPDATABLE)
,m_bEscapeProcessing(true)
{
m_pConnection->acquire();
sal_Int32 nAttrib = 0;
registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CURSORNAME), PROPERTY_ID_CURSORNAME, nAttrib,&m_aCursorName, ::cppu::UnoType<OUString>::get());
......@@ -121,17 +118,9 @@ void OStatement_BASE2::disposing()
m_aSQLIterator.dispose();
if(m_pTable)
{
m_pTable->release();
m_pTable = nullptr;
}
m_pTable.clear();
if (m_pConnection)
{
m_pConnection->release();
m_pConnection = nullptr;
}
m_pConnection.clear();
dispose_ChildImpl();
......@@ -279,7 +268,7 @@ Reference< XResultSet > SAL_CALL OStatement::executeQuery( const OUString& sql )
Reference< XConnection > SAL_CALL OStatement::getConnection( ) throw(SQLException, RuntimeException, std::exception)
{
return Reference< XConnection >(m_pConnection);
return Reference< XConnection >(m_pConnection.get());
}
sal_Int32 SAL_CALL OStatement::executeUpdate( const OUString& sql ) throw(SQLException, RuntimeException, std::exception)
......@@ -321,7 +310,7 @@ Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeExcep
OSQLAnalyzer* OStatement_Base::createAnalyzer()
{
return new OSQLAnalyzer(m_pConnection);
return new OSQLAnalyzer(m_pConnection.get());
}
void OStatement_Base::anylizeSQL()
......@@ -424,14 +413,10 @@ void OStatement_Base::construct(const OUString& sql) throw(SQLException, Runtim
Reference< css::lang::XUnoTunnel> xTunnel(rTabs.begin()->second,UNO_QUERY);
if(xTunnel.is())
{
if(m_pTable)
m_pTable->release();
m_pTable = reinterpret_cast<OFileTable*>(xTunnel->getSomething(OFileTable::getUnoTunnelImplementationId()));
if(m_pTable)
m_pTable->acquire();
}
OSL_ENSURE(m_pTable,"No table!");
if ( m_pTable )
OSL_ENSURE(m_pTable.is(),"No table!");
if ( m_pTable.is() )
m_xColNames = m_pTable->getColumns();
Reference<XIndexAccess> xNames(m_xColNames,UNO_QUERY);
// set the binding of the resultrow
......
......@@ -68,7 +68,6 @@ java_sql_Statement_Base::java_sql_Statement_Base( JNIEnv * pEnv, java_sql_Connec
,m_nResultSetType(ResultSetType::FORWARD_ONLY)
,m_bEscapeProcessing(true)
{
m_pConnection->acquire();
}
......@@ -88,9 +87,7 @@ void SAL_CALL OStatement_BASE2::disposing()
}
::comphelper::disposeComponent(m_xGeneratedStatement);
if (m_pConnection)
m_pConnection->release();
m_pConnection = nullptr;
m_pConnection.clear();
dispose_ChildImpl();
java_sql_Statement_Base::disposing();
......@@ -120,7 +117,7 @@ void SAL_CALL OStatement_BASE2::release() throw()
Any SAL_CALL java_sql_Statement_Base::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
{
if ( m_pConnection && !m_pConnection->isAutoRetrievingEnabled() && rType == cppu::UnoType<XGeneratedResultSet>::get())
if ( m_pConnection.is() && !m_pConnection->isAutoRetrievingEnabled() && rType == cppu::UnoType<XGeneratedResultSet>::get())
return Any();
Any aRet( java_sql_Statement_BASE::queryInterface(rType) );
return aRet.hasValue() ? aRet : OPropertySetHelper::queryInterface(rType);
......@@ -133,7 +130,7 @@ Sequence< Type > SAL_CALL java_sql_Statement_Base::getTypes( ) throw(RuntimeExc
cppu::UnoType<css::beans::XPropertySet>::get());
Sequence< Type > aOldTypes = java_sql_Statement_BASE::getTypes();
if ( m_pConnection && !m_pConnection->isAutoRetrievingEnabled() )
if ( m_pConnection.is() && !m_pConnection->isAutoRetrievingEnabled() )
{
::std::remove(aOldTypes.getArray(),aOldTypes.getArray() + aOldTypes.getLength(),
cppu::UnoType<XGeneratedResultSet>::get());
......@@ -166,8 +163,8 @@ Reference< XResultSet > SAL_CALL java_sql_Statement_Base::getGeneratedValues( )
Reference< XResultSet > xRes;
if ( !out )
{
OSL_ENSURE( m_pConnection && m_pConnection->isAutoRetrievingEnabled(),"Illegal call here. isAutoRetrievingEnabled is false!");
if ( m_pConnection )
OSL_ENSURE( m_pConnection.is() && m_pConnection->isAutoRetrievingEnabled(),"Illegal call here. isAutoRetrievingEnabled is false!");
if ( m_pConnection.is() )
{
OUString sStmt = m_pConnection->getTransformedGeneratedStatement(m_sSqlStatement);
if ( !sStmt.isEmpty() )
......@@ -238,7 +235,7 @@ sal_Bool SAL_CALL java_sql_Statement_Base::execute( const OUString& sql ) throw(
jdbc::LocalRef< jstring > str( t.env(), convertwchar_tToJavaString( t.pEnv, sql ) );
{
jdbc::ContextClassLoaderScope ccl( t.env(),
m_pConnection ? m_pConnection->getDriverClassLoader() : jdbc::GlobalRef< jobject >(),
m_pConnection.is() ? m_pConnection->getDriverClassLoader() : jdbc::GlobalRef< jobject >(),
m_aLogger,
*this
);
......@@ -273,7 +270,7 @@ Reference< XResultSet > SAL_CALL java_sql_Statement_Base::executeQuery( const OU
jdbc::LocalRef< jstring > str( t.env(), convertwchar_tToJavaString( t.pEnv, sql ) );
{
jdbc::ContextClassLoaderScope ccl( t.env(),
m_pConnection ? m_pConnection->getDriverClassLoader() : jdbc::GlobalRef< jobject >(),
m_pConnection.is() ? m_pConnection->getDriverClassLoader() : jdbc::GlobalRef< jobject >(),
m_aLogger,
*this
);
......@@ -290,7 +287,7 @@ Reference< XConnection > SAL_CALL java_sql_Statement_Base::getConnection( ) thr
{
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
return Reference< XConnection >(m_pConnection);
return Reference< XConnection >(m_pConnection.get());
}
......
......@@ -142,7 +142,7 @@ void SAL_CALL java_sql_PreparedStatement::setString( sal_Int32 parameterIndex, c
css::uno::Reference< css::sdbc::XConnection > SAL_CALL java_sql_PreparedStatement::getConnection( ) throw(css::sdbc::SQLException, css::uno::RuntimeException, std::exception)
{
return Reference< XConnection >(m_pConnection);
return Reference< XConnection >(m_pConnection.get());
}
......
......@@ -179,7 +179,7 @@ Reference< XConnection > SAL_CALL OPreparedStatement::getConnection( ) throw(SQ
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
return Reference< XConnection >(m_pConnection);
return Reference< XConnection >(m_pConnection.get());
}
......
......@@ -69,7 +69,6 @@ OCommonStatement::OCommonStatement(OConnection* _pConnection )
{
m_xDBMetaData = _pConnection->getMetaData();
m_pParseTree = nullptr;
m_pConnection->acquire();
}
......@@ -85,9 +84,7 @@ void OCommonStatement::disposing()
clearWarnings();
clearCachedResultSet();
if (m_pConnection)
m_pConnection->release();
m_pConnection = nullptr;
m_pConnection.clear();
m_pSQLIterator->dispose();
delete m_pParseTree;
......@@ -276,7 +273,7 @@ Reference< XConnection > SAL_CALL OCommonStatement::getConnection( ) throw(SQLE
checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
// just return our connection here
return Reference< XConnection >(m_pConnection);
return Reference< XConnection >(m_pConnection.get());
}
Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
......
......@@ -64,7 +64,7 @@ namespace connectivity
// for this Statement
OTable* m_pTable;
OConnection* m_pConnection; // The owning Connection object
rtl::Reference<OConnection> m_pConnection; // The owning Connection object
OValueRow m_aRow;
......@@ -130,7 +130,7 @@ namespace connectivity
public:
// other methods
OConnection* getOwnConnection() const { return m_pConnection;}
OConnection* getOwnConnection() const { return m_pConnection.get(); }
explicit OCommonStatement(OConnection* _pConnection );
using OCommonStatement_IBASE::operator css::uno::Reference< css::uno::XInterface >;
......
......@@ -171,7 +171,7 @@ sal_Bool SAL_CALL OPreparedStatement::execute( ) throw(SQLException, RuntimeExc
{
SQLRETURN nReturn = N3SQLExecute(m_aStatementHandle);
OTools::ThrowException(m_pConnection,nReturn,m_aStatementHandle,SQL_HANDLE_STMT,*this);
OTools::ThrowException(m_pConnection.get(),nReturn,m_aStatementHandle,SQL_HANDLE_STMT,*this);
bool needData = nReturn == SQL_NEED_DATA;
// Now loop while more data is needed (i.e. a data-at-
......@@ -247,7 +247,7 @@ Reference< XConnection > SAL_CALL OPreparedStatement::getConnection( ) throw(SQ
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
return Reference< XConnection >(m_pConnection);
return Reference< XConnection >(m_pConnection.get());
}
......@@ -409,7 +409,7 @@ void OPreparedStatement::setParameter(const sal_Int32 parameterIndex, const sal_
_nDataAllocLen,
&rDataLen);
OTools::ThrowException(m_pConnection, nRetcode, m_aStatementHandle, SQL_HANDLE_STMT, *this);
OTools::ThrowException(m_pConnection.get(), nRetcode, m_aStatementHandle, SQL_HANDLE_STMT, *this);
}
void SAL_CALL OPreparedStatement::setByte( const sal_Int32 parameterIndex, const sal_Int8 x ) throw(SQLException, RuntimeException, std::exception)
......@@ -546,7 +546,7 @@ void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, const sal_I
0,
lenBuf
);
OTools::ThrowException(m_pConnection,nReturn,m_aStatementHandle,SQL_HANDLE_STMT,*this);
OTools::ThrowException(m_pConnection.get(),nReturn,m_aStatementHandle,SQL_HANDLE_STMT,*this);
}
......@@ -917,7 +917,7 @@ void OPreparedStatement::prepareStatement()
OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
OString aSql(OUStringToOString(m_sSqlStatement,getOwnConnection()->getTextEncoding()));
SQLRETURN nReturn = N3SQLPrepare(m_aStatementHandle, reinterpret_cast<SDB_ODBC_CHAR *>(const_cast<char *>(aSql.getStr())), aSql.getLength());
OTools::ThrowException(m_pConnection,nReturn,m_aStatementHandle,SQL_HANDLE_STMT,*this);
OTools::ThrowException(m_pConnection.get(),nReturn,m_aStatementHandle,SQL_HANDLE_STMT,*this);
m_bPrepared = true;
initBoundParam();
}
......
......@@ -41,7 +41,7 @@
using namespace ::comphelper;
#define THROW_SQL(x) \
OTools::ThrowException(m_pConnection,x,m_aStatementHandle,SQL_HANDLE_STMT,*this)
OTools::ThrowException(m_pConnection.get(),x,m_aStatementHandle,SQL_HANDLE_STMT,*this)
using namespace connectivity::odbc;
......@@ -63,7 +63,6 @@ OStatement_Base::OStatement_Base(OConnection* _pConnection )
,m_pRowStatusArray(nullptr)
{
osl_atomic_increment( &m_refCount );
m_pConnection->acquire();
m_aStatementHandle = m_pConnection->createStatementHandle();
//setMaxFieldSize(0);
......@@ -101,11 +100,10 @@ void SAL_CALL OStatement_Base::disposing()
::comphelper::disposeComponent(m_xGeneratedStatement);
OSL_ENSURE(m_aStatementHandle,"OStatement_BASE2::disposing: StatementHandle is null!");
if (m_pConnection)
if (m_pConnection.is())
{
m_pConnection->freeStatementHandle(m_aStatementHandle);
m_pConnection->release();
m_pConnection = nullptr;
m_pConnection.clear();
}
OSL_ENSURE(!m_aStatementHandle,"Sohould ne null here!");
......@@ -127,7 +125,7 @@ void SAL_CALL OStatement_BASE2::release() throw()
Any SAL_CALL OStatement_Base::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
{
if ( m_pConnection && !m_pConnection->isAutoRetrievingEnabled() && rType == cppu::UnoType<XGeneratedResultSet>::get())
if ( m_pConnection.is() && !m_pConnection->isAutoRetrievingEnabled() && rType == cppu::UnoType<XGeneratedResultSet>::get())
return Any();
Any aRet = OStatement_BASE::queryInterface(rType);
return aRet.hasValue() ? aRet : OPropertySetHelper::queryInterface(rType);
......@@ -139,7 +137,7 @@ Sequence< Type > SAL_CALL OStatement_Base::getTypes( ) throw(RuntimeException,
cppu::UnoType<XFastPropertySet>::get(),
cppu::UnoType<XPropertySet>::get());
Sequence< Type > aOldTypes = OStatement_BASE::getTypes();
if ( m_pConnection && !m_pConnection->isAutoRetrievingEnabled() )
if ( m_pConnection.is() && !m_pConnection->isAutoRetrievingEnabled() )
{
::std::remove(aOldTypes.getArray(),aOldTypes.getArray() + aOldTypes.getLength(),
cppu::UnoType<XGeneratedResultSet>::get());
......@@ -151,9 +149,9 @@ Sequence< Type > SAL_CALL OStatement_Base::getTypes( ) throw(RuntimeException,
Reference< XResultSet > SAL_CALL OStatement_Base::getGeneratedValues( ) throw (SQLException, RuntimeException, std::exception)
{
OSL_ENSURE( m_pConnection && m_pConnection->isAutoRetrievingEnabled(),"Illegal call here. isAutoRetrievingEnabled is false!");
OSL_ENSURE( m_pConnection.is() && m_pConnection->isAutoRetrievingEnabled(),"Illegal call here. isAutoRetrievingEnabled is false!");
Reference< XResultSet > xRes;
if ( m_pConnection )
if ( m_pConnection.is() )
{
OUString sStmt = m_pConnection->getTransformedGeneratedStatement(m_sSqlStatement);
if ( !sStmt.isEmpty() )
......@@ -465,7 +463,7 @@ Reference< XConnection > SAL_CALL OStatement_Base::getConnection( ) throw(SQLEx
::osl::MutexGuard aGuard( m_aMutex );
checkDisposed(OStatement_BASE::rBHelper.bDisposed);
return Reference< XConnection >(m_pConnection);
return Reference< XConnection >(m_pConnection.get());
}
......
......@@ -90,7 +90,7 @@ namespace connectivity
OSortIndex* m_pSortIndex;
::rtl::Reference<connectivity::OSQLColumns> m_xColumns; // this are the select columns
::rtl::Reference<connectivity::OSQLColumns> m_xParamColumns;
OFileTable* m_pTable;
rtl::Reference<OFileTable> m_pTable;
connectivity::OSQLParseNode* m_pParseTree;
OSQLAnalyzer* m_pSQLAnalyzer;
......
......@@ -76,11 +76,11 @@ namespace connectivity
connectivity::OSQLParser m_aParser;
connectivity::OSQLParseTreeIterator m_aSQLIterator;
OConnection* m_pConnection;// The owning Connection object
rtl::Reference<OConnection> m_pConnection;// The owning Connection object
connectivity::OSQLParseNode* m_pParseTree;
OSQLAnalyzer* m_pSQLAnalyzer; //the sql analyzer used by the resultset
OFileTable* m_pTable; // the current table
rtl::Reference<OFileTable> m_pTable; // the current table
OValueRefRow m_aSelectRow;
OValueRefRow m_aRow;
OValueRefRow m_aEvaluateRow; // contains all values of a row
......@@ -133,7 +133,7 @@ namespace connectivity
OStatement_Base(OConnection* _pConnection );
OConnection* getOwnConnection() const { return m_pConnection;}
OConnection* getOwnConnection() const { return m_pConnection.get(); }
using OStatement_BASE::operator css::uno::Reference< css::uno::XInterface >;
......
......@@ -79,7 +79,7 @@ namespace connectivity
protected:
css::uno::Reference< css::sdbc::XStatement> m_xGeneratedStatement;
java_sql_Connection* m_pConnection;
rtl::Reference<java_sql_Connection> m_pConnection;