connectivity/source/drivers/firebird/Driver.cxx | 4 ++-- connectivity/source/drivers/firebird/Driver.hxx | 4 +++- dbaccess/source/core/dataaccess/connection.cxx | 8 ++++---- dbaccess/source/core/inc/connection.hxx | 6 +++++- 4 files changed, 14 insertions(+), 8 deletions(-)
New commits: commit 1b3da13029312f9e921f213bef9ef5aa51eb7946 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Mar 5 12:51:50 2025 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Mar 5 17:09:57 2025 +0100 improve type-safety in FirebirdDriver Change-Id: I110d7d2c10d5855b6486d84763b7e963de1617f7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182532 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/connectivity/source/drivers/firebird/Driver.cxx b/connectivity/source/drivers/firebird/Driver.cxx index 167072ca71c8..9ed42abe6fc9 100644 --- a/connectivity/source/drivers/firebird/Driver.cxx +++ b/connectivity/source/drivers/firebird/Driver.cxx @@ -99,7 +99,7 @@ void FirebirdDriver::disposing() for (auto const& elem : m_xConnections) { - Reference< XComponent > xComp(elem.get(), UNO_QUERY); + rtl::Reference< Connection > xComp(elem.get()); if (xComp.is()) xComp->dispose(); } @@ -151,7 +151,7 @@ Reference< XConnection > SAL_CALL FirebirdDriver::connect( rtl::Reference<Connection> pCon = new Connection(); pCon->construct(url, info); - m_xConnections.emplace_back(*pCon); + m_xConnections.push_back(pCon); return pCon; } diff --git a/connectivity/source/drivers/firebird/Driver.hxx b/connectivity/source/drivers/firebird/Driver.hxx index d884b5008d6a..f126413aba94 100644 --- a/connectivity/source/drivers/firebird/Driver.hxx +++ b/connectivity/source/drivers/firebird/Driver.hxx @@ -27,6 +27,7 @@ #include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp> #include <cppuhelper/compbase.hxx> #include <unotools/tempfile.hxx> +#include <unotools/weakref.hxx> namespace connectivity::firebird { @@ -50,7 +51,8 @@ namespace connectivity::firebird protected: ::osl::Mutex m_aMutex; // mutex is need to control member access - OWeakRefArray m_xConnections; // vector containing a list + std::vector<unotools::WeakReference<Connection>> + m_xConnections; // vector containing a list // of all the Connection objects // for this Driver commit 6e031fc7d6f039d03b537c2e4f90b6de1fde13f5 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Mar 5 12:49:12 2025 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Mar 5 17:09:48 2025 +0100 improve type-safety in dbaccess::OConnection Change-Id: I39ebd277431407b65c5c4a80698714399d39330f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182531 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Jenkins diff --git a/dbaccess/source/core/dataaccess/connection.cxx b/dbaccess/source/core/dataaccess/connection.cxx index d1543a36c036..808d4128138c 100644 --- a/dbaccess/source/core/dataaccess/connection.cxx +++ b/dbaccess/source/core/dataaccess/connection.cxx @@ -111,7 +111,7 @@ Reference< XStatement > OConnection::createStatement() MutexGuard aGuard(m_aMutex); checkDisposed(); - Reference< XStatement > xStatement; + rtl::Reference< OStatement > xStatement; Reference< XStatement > xMasterStatement = m_xMasterConnection->createStatement(); if ( xMasterStatement.is() ) { @@ -127,7 +127,7 @@ Reference< XPreparedStatement > OConnection::prepareStatement(const OUString& s checkDisposed(); // TODO convert the SQL to SQL the driver understands - Reference< XPreparedStatement > xStatement; + rtl::Reference< OPreparedStatement > xStatement; Reference< XPreparedStatement > xMasterStatement = m_xMasterConnection->prepareStatement(sql); if ( xMasterStatement.is() ) { @@ -142,7 +142,7 @@ Reference< XPreparedStatement > OConnection::prepareCall(const OUString& sql) MutexGuard aGuard(m_aMutex); checkDisposed(); - Reference< XPreparedStatement > xStatement; + rtl::Reference< OCallableStatement > xStatement; Reference< XPreparedStatement > xMasterStatement = m_xMasterConnection->prepareCall(sql); if ( xMasterStatement.is() ) { @@ -428,7 +428,7 @@ void OConnection::disposing() for (auto const& statement : m_aStatements) { - Reference<XComponent> xComp(statement.get(),UNO_QUERY); + rtl::Reference<OStatementBase> xComp(statement.get()); ::comphelper::disposeComponent(xComp); } m_aStatements.clear(); diff --git a/dbaccess/source/core/inc/connection.hxx b/dbaccess/source/core/inc/connection.hxx index 28596999880d..31f2c924bde1 100644 --- a/dbaccess/source/core/inc/connection.hxx +++ b/dbaccess/source/core/inc/connection.hxx @@ -49,6 +49,8 @@ #include <connectivity/warningscontainer.hxx> #include <unotools/weakref.hxx> +class OStatementBase; + namespace dbaccess { @@ -76,7 +78,9 @@ class OConnection final :public OConnection_Base unotools::WeakReference<ODatabaseSource> m_xParent; css::uno::Reference< css::sdbcx::XTablesSupplier > m_xMasterTables; // just to avoid the recreation of the catalog - connectivity::OWeakRefArray m_aStatements; + // contains OStatement and OPreparedStatement + std::vector<unotools::WeakReference<OStatementBase>> + m_aStatements; rtl::Reference< OQueryContainer > m_xQueries; connectivity::OWeakRefArray m_aComposers;