dbaccess/source/core/api/RowSet.cxx | 20 ++++++++++---------- dbaccess/source/core/api/RowSet.hxx | 5 +++-- 2 files changed, 13 insertions(+), 12 deletions(-)
New commits: commit 26fd88df801c91117b8819e2a1afb898d2612eba Author: Noel Grandin <[email protected]> AuthorDate: Tue Sep 17 19:20:51 2024 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Wed Sep 18 08:06:55 2024 +0200 remove OSubComponent from RowSet which attempts to implement a very dodgy and almost but not actually thread-safe dispose function. Rather just hold a weak reference to the rowset that created us. Change-Id: I1881ac34320b61866eefc3641b455f618d0759d2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173573 Reviewed-by: Noel Grandin <[email protected]> Tested-by: Jenkins diff --git a/dbaccess/source/core/api/RowSet.cxx b/dbaccess/source/core/api/RowSet.cxx index 46c4984f7439..0b6e7c5a885a 100644 --- a/dbaccess/source/core/api/RowSet.cxx +++ b/dbaccess/source/core/api/RowSet.cxx @@ -2708,9 +2708,9 @@ void ORowSet::impl_rebuild_throw(::osl::ResettableMutexGuard& _rGuard) // *********************************************************** ORowSetClone::ORowSetClone( const Reference<XComponentContext>& _rContext, ORowSet& rParent, ::osl::Mutex* _pMutex ) - :OSubComponent(m_aMutex, rParent) + : ::cppu::WeakComponentImplHelper<>(m_aMutex) ,ORowSetBase( _rContext, WeakComponentImplHelper::rBHelper, _pMutex ) - ,m_pParent(&rParent) + ,m_xParent(&rParent) ,m_nFetchDirection(rParent.m_nFetchDirection) ,m_nFetchSize(rParent.m_nFetchSize) ,m_bIsBookmarkable(true) @@ -2801,7 +2801,7 @@ ORowSetClone::~ORowSetClone() // css::XTypeProvider Sequence< Type > ORowSetClone::getTypes() { - return ::comphelper::concatSequences(OSubComponent::getTypes(),ORowSetBase::getTypes()); + return ::comphelper::concatSequences(::cppu::WeakComponentImplHelper<>::getTypes(),ORowSetBase::getTypes()); } // css::XInterface @@ -2809,18 +2809,18 @@ Any ORowSetClone::queryInterface( const Type & rType ) { Any aRet = ORowSetBase::queryInterface(rType); if(!aRet.hasValue()) - aRet = OSubComponent::queryInterface(rType); + aRet = ::cppu::WeakComponentImplHelper<>::queryInterface(rType); return aRet; } void ORowSetClone::acquire() noexcept { - OSubComponent::acquire(); + ::cppu::WeakComponentImplHelper<>::acquire(); } void ORowSetClone::release() noexcept { - OSubComponent::release(); + ::cppu::WeakComponentImplHelper<>::release(); } // XServiceInfo @@ -2845,9 +2845,9 @@ void ORowSetClone::disposing() MutexGuard aGuard( m_aMutex ); ORowSetBase::disposing(); - m_pParent = nullptr; + m_xParent = nullptr; m_pMutex = &m_aMutex; // this must be done here because someone could hold a ref to us and try to do something - OSubComponent::disposing(); + ::cppu::WeakComponentImplHelper<>::disposing(); } // XCloseable @@ -2879,8 +2879,8 @@ void SAL_CALL ORowSetClone::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,c { if ( nHandle == PROPERTY_ID_FETCHSIZE ) { - if ( m_pParent ) - m_pParent->setFastPropertyValue_NoBroadcast( nHandle, rValue ); + if ( auto xParent = m_xParent.get() ) + xParent->setFastPropertyValue_NoBroadcast( nHandle, rValue ); } OPropertyStateContainer::setFastPropertyValue_NoBroadcast(nHandle,rValue); diff --git a/dbaccess/source/core/api/RowSet.hxx b/dbaccess/source/core/api/RowSet.hxx index 3cf6fe690193..92d9e53f7461 100644 --- a/dbaccess/source/core/api/RowSet.hxx +++ b/dbaccess/source/core/api/RowSet.hxx @@ -48,6 +48,7 @@ #include <connectivity/paramwrapper.hxx> #include <connectivity/FValue.hxx> #include <connectivity/warningscontainer.hxx> +#include <unotools/weakref.hxx> namespace dbaccess { @@ -445,11 +446,11 @@ namespace dbaccess // ORowSetClone class ORowSetClone : public cppu::BaseMutex - ,public OSubComponent + ,public ::cppu::WeakComponentImplHelper<> ,public ORowSetBase ,public ::comphelper::OPropertyArrayUsageHelper < ORowSetClone > { - ORowSet* m_pParent; + unotools::WeakReference<ORowSet> m_xParent; sal_Int32 m_nFetchDirection; sal_Int32 m_nFetchSize; bool m_bIsBookmarkable;
