summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2015-08-05 10:48:40 +0200
committerNoel Grandin <noelgrandin@gmail.com>2015-08-05 11:26:04 +0000
commit9c1f700aff5f7e375d3570231e6d68fe2e2c0334 (patch)
tree0d616e27ab7cf82dd5e28939b984a626adc682e0 /dbaccess
parenta5b842f3aa401352f5454edb8f47d9576dff0092 (diff)
improve refcounting loplugin to check SvRef-based classes
Change-Id: I2b3c8eedabeaecd8dcae9fe69c951353a5686883 Reviewed-on: https://gerrit.libreoffice.org/17521 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'dbaccess')
-rw-r--r--dbaccess/source/core/api/KeySet.cxx18
-rw-r--r--dbaccess/source/core/api/KeySet.hxx4
-rw-r--r--dbaccess/source/core/api/RowSet.cxx28
-rw-r--r--dbaccess/source/core/api/RowSet.hxx4
-rw-r--r--dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx2
-rw-r--r--dbaccess/source/ui/querydesign/querycontroller.cxx2
6 files changed, 30 insertions, 28 deletions
diff --git a/dbaccess/source/core/api/KeySet.cxx b/dbaccess/source/core/api/KeySet.cxx
index 404e01652836..060f028ebd80 100644
--- a/dbaccess/source/core/api/KeySet.cxx
+++ b/dbaccess/source/core/api/KeySet.cxx
@@ -111,7 +111,7 @@ OKeySet::OKeySet(const connectivity::OSQLTable& _xTable,
sal_Int32 i_nMaxRows,
sal_Int32& o_nRowCount)
:OCacheSet(i_nMaxRows)
- ,m_aParameterValueForCache(_aParameterValueForCache)
+ ,m_aParameterValueForCache(new ORowSetValueVector(_aParameterValueForCache))
,m_xTable(_xTable)
,m_xTableKeys(_xTableKeys)
,m_xComposer(_xComposer)
@@ -824,8 +824,8 @@ void OKeySet::copyRowValue(const ORowSetRow& _rInsertRow,ORowSetRow& _rKeyRow,sa
connectivity::ORowVector< ORowSetValue >::Vector::iterator aIter = _rKeyRow->get().begin();
// check the if the parameter values have been changed
- OSL_ENSURE((m_aParameterValueForCache.get().size()-1) == m_pParameterNames->size(),"OKeySet::copyRowValue: Parameter values and names differ!");
- connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaValuesIter = m_aParameterValueForCache.get().begin() +1;
+ OSL_ENSURE((m_aParameterValueForCache->get().size()-1) == m_pParameterNames->size(),"OKeySet::copyRowValue: Parameter values and names differ!");
+ connectivity::ORowVector< ORowSetValue >::Vector::const_iterator aParaValuesIter = m_aParameterValueForCache->get().begin() +1;
bool bChanged = false;
SelectColumnsMetaData::const_iterator aParaIter = (*m_pParameterNames).begin();
@@ -836,8 +836,8 @@ void OKeySet::copyRowValue(const ORowSetRow& _rInsertRow,ORowSetRow& _rKeyRow,sa
aValue.setSigned(m_aSignedFlags[aParaIter->second.nPosition]);
if ( (_rInsertRow->get())[aParaIter->second.nPosition] != aValue )
{
- ORowSetValueVector aCopy(m_aParameterValueForCache);
- (aCopy.get())[i] = (_rInsertRow->get())[aParaIter->second.nPosition];
+ rtl::Reference<ORowSetValueVector> aCopy(new ORowSetValueVector(*m_aParameterValueForCache.get()));
+ (aCopy->get())[i] = (_rInsertRow->get())[aParaIter->second.nPosition];
m_aUpdatedParameter[i_nBookmark] = aCopy;
bChanged = true;
}
@@ -1192,13 +1192,13 @@ bool OKeySet::doTryRefetch_throw() throw(SQLException, RuntimeException)
OUpdatedParameter::iterator aUpdateFind = m_aUpdatedParameter.find(m_aKeyIter->first);
if ( aUpdateFind == m_aUpdatedParameter.end() )
{
- aParaIter = m_aParameterValueForCache.get().begin();
- aParaEnd = m_aParameterValueForCache.get().end();
+ aParaIter = m_aParameterValueForCache->get().begin();
+ aParaEnd = m_aParameterValueForCache->get().end();
}
else
{
- aParaIter = aUpdateFind->second.get().begin();
- aParaEnd = aUpdateFind->second.get().end();
+ aParaIter = aUpdateFind->second->get().begin();
+ aParaEnd = aUpdateFind->second->get().end();
}
for(++aParaIter;aParaIter != aParaEnd;++aParaIter,++nPos)
diff --git a/dbaccess/source/core/api/KeySet.hxx b/dbaccess/source/core/api/KeySet.hxx
index 6ce838e2131b..945684f611d3 100644
--- a/dbaccess/source/core/api/KeySet.hxx
+++ b/dbaccess/source/core/api/KeySet.hxx
@@ -72,7 +72,7 @@ namespace dbaccess
typedef ::std::pair<ORowSetRow,::std::pair<sal_Int32,css::uno::Reference< css::sdbc::XRow> > > OKeySetValue;
typedef ::std::map<sal_Int32,OKeySetValue > OKeySetMatrix;
- typedef ::std::map<sal_Int32,ORowSetValueVector > OUpdatedParameter;
+ typedef ::std::map<sal_Int32, rtl::Reference<ORowSetValueVector> > OUpdatedParameter;
// is used when the source supports keys
class OKeySet : public OCacheSet
{
@@ -83,7 +83,7 @@ namespace dbaccess
::std::vector< OUString > m_aAutoColumns; // contains all columns which are autoincrement ones
OUpdatedParameter m_aUpdatedParameter; // contains all parameter which have been updated and are needed for refetching
- ORowSetValueVector m_aParameterValueForCache;
+ rtl::Reference<ORowSetValueVector> m_aParameterValueForCache;
::std::unique_ptr<SelectColumnsMetaData> m_pKeyColumnNames; // contains all key column names
::std::unique_ptr<SelectColumnsMetaData> m_pColumnNames; // contains all column names
::std::unique_ptr<SelectColumnsMetaData> m_pParameterNames; // contains all parameter names
diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx
index 9e03c14b086f..70a419a64c03 100644
--- a/dbaccess/source/core/api/RowSet.cxx
+++ b/dbaccess/source/core/api/RowSet.cxx
@@ -134,6 +134,8 @@ ORowSet::ORowSet( const Reference< css::uno::XComponentContext >& _rxContext )
:ORowSet_BASE1(m_aMutex)
,ORowSetBase( _rxContext, ORowSet_BASE1::rBHelper, &m_aMutex )
,m_pParameters( NULL )
+ ,m_aPrematureParamValues(new ORowSetValueVector)
+ ,m_aParameterValueForCache(new ORowSetValueVector)
,m_aRowsetListeners(*m_pMutex)
,m_aApproveListeners(*m_pMutex)
,m_aRowsChangeListener(*m_pMutex)
@@ -170,7 +172,7 @@ ORowSet::ORowSet( const Reference< css::uno::XComponentContext >& _rxContext )
sal_Int32 nRT = PropertyAttribute::READONLY | PropertyAttribute::TRANSIENT;
sal_Int32 nBT = PropertyAttribute::BOUND | PropertyAttribute::TRANSIENT;
- m_aPrematureParamValues.get().resize( 0 );
+ m_aPrematureParamValues->get().resize( 0 );
// sdb.RowSet Properties
registerMayBeVoidProperty(PROPERTY_ACTIVE_CONNECTION,PROPERTY_ID_ACTIVE_CONNECTION, PropertyAttribute::MAYBEVOID|PropertyAttribute::TRANSIENT|PropertyAttribute::BOUND, &m_aActiveConnection, cppu::UnoType<XConnection>::get());
@@ -1681,14 +1683,14 @@ Reference< XResultSet > ORowSet::impl_prepareAndExecute_throw()
{
impl_ensureStatement_throw();
- m_aParameterValueForCache.get().resize(1);
+ m_aParameterValueForCache->get().resize(1);
Reference< XParameters > xParam( m_xStatement, UNO_QUERY_THROW );
- size_t nParamCount( m_pParameters.is() ? m_pParameters->size() : m_aPrematureParamValues.get().size() );
+ size_t nParamCount( m_pParameters.is() ? m_pParameters->size() : m_aPrematureParamValues->get().size() );
for ( size_t i=1; i<=nParamCount; ++i )
{
ORowSetValue& rParamValue( getParameterStorage( (sal_Int32)i ) );
::dbtools::setObjectWithInfo( xParam, i, rParamValue.makeAny(), rParamValue.getTypeKind() );
- m_aParameterValueForCache.get().push_back(rParamValue);
+ m_aParameterValueForCache->get().push_back(rParamValue);
}
m_bParametersDirty = false;
@@ -1703,7 +1705,7 @@ Reference< XResultSet > ORowSet::impl_prepareAndExecute_throw()
{
DELETEZ(m_pCache);
}
- m_pCache = new ORowSetCache( xResultSet, m_xComposer.get(), m_aContext, aComposedUpdateTableName, m_bModified, m_bNew,m_aParameterValueForCache,m_aFilter,m_nMaxRows );
+ m_pCache = new ORowSetCache( xResultSet, m_xComposer.get(), m_aContext, aComposedUpdateTableName, m_bModified, m_bNew, *m_aParameterValueForCache.get(),m_aFilter,m_nMaxRows );
if ( m_nResultSetConcurrency == ResultSetConcurrency::READ_ONLY )
{
m_nPrivileges = Privilege::SELECT;
@@ -2432,10 +2434,10 @@ void ORowSet::impl_initParametersContainer_nothrow()
m_pParameters = new param::ParameterWrapperContainer( m_xComposer.get() );
// copy the premature parameters into the final ones
- size_t nParamCount( ::std::min( m_pParameters->size(), m_aPrematureParamValues.get().size() ) );
+ size_t nParamCount( ::std::min( m_pParameters->size(), m_aPrematureParamValues->get().size() ) );
for ( size_t i=0; i<nParamCount; ++i )
{
- (*m_pParameters)[i] = m_aPrematureParamValues.get()[i];
+ (*m_pParameters)[i] = m_aPrematureParamValues->get()[i];
}
}
@@ -2446,10 +2448,10 @@ void ORowSet::impl_disposeParametersContainer_nothrow()
// copy the actual values to our "premature" ones, to preserve them for later use
size_t nParamCount( m_pParameters->size() );
- m_aPrematureParamValues.get().resize( nParamCount );
+ m_aPrematureParamValues->get().resize( nParamCount );
for ( size_t i=0; i<nParamCount; ++i )
{
- m_aPrematureParamValues.get()[i] = (*m_pParameters)[i];
+ m_aPrematureParamValues->get()[i] = (*m_pParameters)[i];
}
m_pParameters->dispose();
@@ -2480,9 +2482,9 @@ ORowSetValue& ORowSet::getParameterStorage(sal_Int32 parameterIndex)
}
}
- if ( m_aPrematureParamValues.get().size() < (size_t)parameterIndex )
- m_aPrematureParamValues.get().resize( parameterIndex );
- return m_aPrematureParamValues.get()[ parameterIndex - 1 ];
+ if ( m_aPrematureParamValues->get().size() < (size_t)parameterIndex )
+ m_aPrematureParamValues->get().resize( parameterIndex );
+ return m_aPrematureParamValues->get()[ parameterIndex - 1 ];
}
// XParameters
@@ -2655,7 +2657,7 @@ void SAL_CALL ORowSet::clearParameters( ) throw(SQLException, RuntimeException,
::osl::MutexGuard aGuard( m_aColumnsMutex );
- size_t nParamCount( m_pParameters.is() ? m_pParameters->size() : m_aPrematureParamValues.get().size() );
+ size_t nParamCount( m_pParameters.is() ? m_pParameters->size() : m_aPrematureParamValues->get().size() );
for ( size_t i=1; i<=nParamCount; ++i )
getParameterStorage( (sal_Int32)i ).setNull();
m_aParametersSet.clear();
diff --git a/dbaccess/source/core/api/RowSet.hxx b/dbaccess/source/core/api/RowSet.hxx
index 845df9af13b5..44e0d56222ea 100644
--- a/dbaccess/source/core/api/RowSet.hxx
+++ b/dbaccess/source/core/api/RowSet.hxx
@@ -86,8 +86,8 @@ namespace dbaccess
/** our parameters values, used when we do not yet have a parameters container
(since we have not been executed, yet)
*/
- ORowSetValueVector m_aPrematureParamValues;
- ORowSetValueVector m_aParameterValueForCache;
+ rtl::Reference<ORowSetValueVector> m_aPrematureParamValues;
+ rtl::Reference<ORowSetValueVector> m_aParameterValueForCache;
::std::vector<bool> m_aParametersSet;
::std::vector<bool> m_aReadOnlyDataColumns;
diff --git a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
index 86fb9f75b581..f02dfa4d15a4 100644
--- a/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
+++ b/dbaccess/source/ui/querydesign/SelectionBrowseBox.cxx
@@ -1391,7 +1391,7 @@ sal_Int8 OSelectionBrowseBox::ExecuteDrop( const BrowserExecuteDropEvent& _rEvt
return DND_ACTION_NONE;
}
- OTableFieldDesc aInfo;
+ rtl::Reference<OTableFieldDesc> aInfo;
// insert the field at the selected position
OJoinExchangeData jxdSource = OJoinExchObj::GetSourceDescription(_rEvt.maDropEvent.Transferable);
InsertField(jxdSource);
diff --git a/dbaccess/source/ui/querydesign/querycontroller.cxx b/dbaccess/source/ui/querydesign/querycontroller.cxx
index 76bd6c1110b2..37976f0aa3f7 100644
--- a/dbaccess/source/ui/querydesign/querycontroller.cxx
+++ b/dbaccess/source/ui/querydesign/querycontroller.cxx
@@ -1252,7 +1252,7 @@ sal_Int32 OQueryController::getColWidth(sal_uInt16 _nColPos) const
{
if ( _nColPos < m_aFieldInformation.getLength() )
{
- ::std::unique_ptr<OTableFieldDesc> pField( new OTableFieldDesc());
+ rtl::Reference<OTableFieldDesc> pField( new OTableFieldDesc());
pField->Load( m_aFieldInformation[ _nColPos ], false );
return pField->GetColWidth();
}