dbaccess/source/core/api/preparedstatement.cxx | 4 ++-- dbaccess/source/core/api/statement.cxx | 11 +++++------ dbaccess/source/core/inc/statement.hxx | 4 ++-- 3 files changed, 9 insertions(+), 10 deletions(-)
New commits: commit d7c17d4a993b746ae92ac1307790f645835e84aa Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Mar 4 10:13:04 2025 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Mar 4 12:07:12 2025 +0100 improve type-safety in dbaccess OStatementBase we can use unotools::WeakReference instead of untyped WeakReferenceHelper. Also rename the field to something more obvious Change-Id: Iff674893ec0c3144830c46d1745c920f910d6067 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182458 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/dbaccess/source/core/api/preparedstatement.cxx b/dbaccess/source/core/api/preparedstatement.cxx index ecb1a4c1e348..506da4908f44 100644 --- a/dbaccess/source/core/api/preparedstatement.cxx +++ b/dbaccess/source/core/api/preparedstatement.cxx @@ -187,14 +187,14 @@ Reference< XResultSet > OPreparedStatement::executeQuery() disposeResultSet(); - Reference< XResultSet > xResultSet; + rtl::Reference< OResultSet > xResultSet; Reference< XResultSet > xDrvResultSet = Reference< XPreparedStatement >( m_xAggregateAsSet, UNO_QUERY_THROW )->executeQuery(); if (xDrvResultSet.is()) { xResultSet = new OResultSet(xDrvResultSet, *this, m_pColumns->isCaseSensitive()); // keep the resultset weak - m_aResultSet = xResultSet; + m_xWeakResultSet = xResultSet.get(); } return xResultSet; } diff --git a/dbaccess/source/core/api/statement.cxx b/dbaccess/source/core/api/statement.cxx index 552a8142d491..0334802ab244 100644 --- a/dbaccess/source/core/api/statement.cxx +++ b/dbaccess/source/core/api/statement.cxx @@ -123,10 +123,9 @@ void OStatementBase::release() noexcept void OStatementBase::disposeResultSet() { // free the cursor if alive - Reference< XComponent > xComp(m_aResultSet.get(), UNO_QUERY); - if (xComp.is()) - xComp->dispose(); - m_aResultSet.clear(); + if (auto xRes = m_xWeakResultSet.get()) + xRes->dispose(); + m_xWeakResultSet.clear(); } // OComponentHelper @@ -454,7 +453,7 @@ Reference< XResultSet > OStatement::executeQuery( const OUString& _rSQL ) ::connectivity::checkDisposed(WeakComponentImplHelper::rBHelper.bDisposed); disposeResultSet(); - Reference< XResultSet > xResultSet; + rtl::Reference< OResultSet > xResultSet; OUString sSQL( impl_doEscapeProcessing_nothrow( _rSQL ) ); @@ -468,7 +467,7 @@ Reference< XResultSet > OStatement::executeQuery( const OUString& _rSQL ) xResultSet = new OResultSet( xInnerResultSet, *this, bCaseSensitive ); // keep the resultset weak - m_aResultSet = xResultSet; + m_xWeakResultSet = xResultSet.get(); } return xResultSet; diff --git a/dbaccess/source/core/inc/statement.hxx b/dbaccess/source/core/inc/statement.hxx index 3ab67085164f..17726d7d0f0b 100644 --- a/dbaccess/source/core/inc/statement.hxx +++ b/dbaccess/source/core/inc/statement.hxx @@ -36,7 +36,7 @@ #include <cppuhelper/compbase.hxx> #include <unotools/weakref.hxx> -namespace dbaccess { class OConnection; } +namespace dbaccess { class OConnection; class OResultSet; } // OStatementBase @@ -55,7 +55,7 @@ protected: unotools::WeakReference<::dbaccess::OConnection> m_xParent; ::osl::Mutex m_aCancelMutex; - css::uno::WeakReferenceHelper m_aResultSet; + unotools::WeakReference<::dbaccess::OResultSet> m_xWeakResultSet; css::uno::Reference< css::beans::XPropertySet > m_xAggregateAsSet; css::uno::Reference< css::util::XCancellable > m_xAggregateAsCancellable; bool m_bUseBookmarks;