connectivity/source/drivers/calc/CDriver.cxx | 2 +- connectivity/source/drivers/dbase/DDriver.cxx | 2 +- connectivity/source/drivers/evoab2/NDriver.cxx | 5 ++--- connectivity/source/drivers/evoab2/NDriver.hxx | 5 ++++- connectivity/source/drivers/file/FDriver.cxx | 6 +++--- connectivity/source/drivers/flat/EDriver.cxx | 2 +- connectivity/source/drivers/writer/WDriver.cxx | 2 +- connectivity/source/inc/file/FDriver.hxx | 5 ++++- 8 files changed, 17 insertions(+), 12 deletions(-)
New commits: commit 0d793d6453d61d81d35d37f359915b351e26d4d6 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Mar 4 13:45:02 2025 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Mar 5 10:23:21 2025 +0100 improve type safety in OEvoabDriver Change-Id: I9b65bdf5ffb4ffd52f2ec8f87eb999c767569948 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182478 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/connectivity/source/drivers/evoab2/NDriver.cxx b/connectivity/source/drivers/evoab2/NDriver.cxx index 2babee09288c..83934b6b3e1a 100644 --- a/connectivity/source/drivers/evoab2/NDriver.cxx +++ b/connectivity/source/drivers/evoab2/NDriver.cxx @@ -51,7 +51,7 @@ void OEvoabDriver::disposing() // when driver will be destroyed so all our connections have to be destroyed as well for (const auto& rxConnection : m_xConnections) { - Reference< XComponent > xComp(rxConnection.get(), UNO_QUERY); + rtl::Reference< OEvoabConnection > xComp(rxConnection); if (xComp.is()) { try @@ -65,7 +65,6 @@ void OEvoabDriver::disposing() } } m_xConnections.clear(); - connectivity::OWeakRefArray().swap(m_xConnections); // this really clears ODriver_BASE::disposing(); } @@ -104,7 +103,7 @@ Reference< XConnection > SAL_CALL OEvoabDriver::connect( const OUString& url, co rtl::Reference<OEvoabConnection> pCon = new OEvoabConnection( *this ); pCon->construct(url,info); - m_xConnections.push_back(WeakReferenceHelper(*pCon)); + m_xConnections.push_back(pCon); return pCon; } diff --git a/connectivity/source/drivers/evoab2/NDriver.hxx b/connectivity/source/drivers/evoab2/NDriver.hxx index b505bb9db5fd..4e4e77e8b476 100644 --- a/connectivity/source/drivers/evoab2/NDriver.hxx +++ b/connectivity/source/drivers/evoab2/NDriver.hxx @@ -27,11 +27,14 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <cppuhelper/compbase.hxx> #include <connectivity/CommonTools.hxx> +#include <unotools/weakref.hxx> inline constexpr OUString EVOAB_DRIVER_IMPL_NAME = u"com.sun.star.comp.sdbc.evoab.OEvoabDriver"_ustr; namespace connectivity::evoab { + class OEvoabConnection; + typedef ::cppu::WeakComponentImplHelper< css::sdbc::XDriver, css::lang::XServiceInfo > ODriver_BASE; @@ -39,7 +42,7 @@ namespace connectivity::evoab class OEvoabDriver final : public ODriver_BASE { ::osl::Mutex m_aMutex; - connectivity::OWeakRefArray m_xConnections; + std::vector<unotools::WeakReference<OEvoabConnection>> m_xConnections; css::uno::Reference< css::uno::XComponentContext > m_xContext; public: commit 0405a139e3cffe8f60f1d6760baeff257a09512c Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Mar 4 13:43:08 2025 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Mar 5 10:23:13 2025 +0100 improve type safety in file::OFileDriver Change-Id: I2150fbd2c23b6bde08443f2eb6eabdcb269376fb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182477 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/connectivity/source/drivers/calc/CDriver.cxx b/connectivity/source/drivers/calc/CDriver.cxx index 1bffa74db424..528df911c219 100644 --- a/connectivity/source/drivers/calc/CDriver.cxx +++ b/connectivity/source/drivers/calc/CDriver.cxx @@ -70,7 +70,7 @@ Reference< XConnection > SAL_CALL ODriver::connect( const OUString& url, rtl::Reference<OCalcConnection> pCon = new OCalcConnection(this); pCon->construct(url,info); - m_xConnections.push_back(WeakReferenceHelper(*pCon)); + m_xConnections.push_back(pCon.get()); return pCon; } diff --git a/connectivity/source/drivers/dbase/DDriver.cxx b/connectivity/source/drivers/dbase/DDriver.cxx index 5191dc61f586..36d44951f0f2 100644 --- a/connectivity/source/drivers/dbase/DDriver.cxx +++ b/connectivity/source/drivers/dbase/DDriver.cxx @@ -66,7 +66,7 @@ Reference< XConnection > SAL_CALL ODriver::connect( const OUString& url, const S rtl::Reference<ODbaseConnection> pCon = new ODbaseConnection(this); pCon->construct(url,info); - m_xConnections.push_back(WeakReferenceHelper(*pCon)); + m_xConnections.push_back(pCon.get()); return pCon; } diff --git a/connectivity/source/drivers/file/FDriver.cxx b/connectivity/source/drivers/file/FDriver.cxx index 1d92b922c15c..e5788a257ddb 100644 --- a/connectivity/source/drivers/file/FDriver.cxx +++ b/connectivity/source/drivers/file/FDriver.cxx @@ -50,7 +50,7 @@ void OFileDriver::disposing() for (auto const& connection : m_xConnections) { - Reference< XComponent > xComp(connection.get(), UNO_QUERY); + rtl::Reference< OConnection > xComp(connection); if (xComp.is()) xComp->dispose(); } @@ -85,7 +85,7 @@ Reference< XConnection > SAL_CALL OFileDriver::connect( const OUString& url, con rtl::Reference<OConnection> pCon = new OConnection(this); pCon->construct(url,info); - m_xConnections.push_back(WeakReferenceHelper(*pCon)); + m_xConnections.push_back(pCon); return pCon; } @@ -176,7 +176,7 @@ Reference< XTablesSupplier > SAL_CALL OFileDriver::getDataDefinitionByConnection { for (auto const& elem : m_xConnections) { - if (static_cast<OConnection*>( Reference< XConnection >::query(elem.get()).get() ) == pSearchConnection) + if (elem.get().get() == pSearchConnection) return pSearchConnection->createCatalog(); } } diff --git a/connectivity/source/drivers/flat/EDriver.cxx b/connectivity/source/drivers/flat/EDriver.cxx index f99a437323dc..e9cb465d327f 100644 --- a/connectivity/source/drivers/flat/EDriver.cxx +++ b/connectivity/source/drivers/flat/EDriver.cxx @@ -68,7 +68,7 @@ Reference< XConnection > SAL_CALL ODriver::connect( const OUString& url, const S rtl::Reference<OFlatConnection> pCon = new OFlatConnection(this); pCon->construct(url,info); - m_xConnections.emplace_back(*pCon); + m_xConnections.push_back(pCon.get()); return pCon; } diff --git a/connectivity/source/drivers/writer/WDriver.cxx b/connectivity/source/drivers/writer/WDriver.cxx index 6129b4a20c4c..daa94aa43f9c 100644 --- a/connectivity/source/drivers/writer/WDriver.cxx +++ b/connectivity/source/drivers/writer/WDriver.cxx @@ -60,7 +60,7 @@ uno::Reference<sdbc::XConnection> rtl::Reference<OWriterConnection> pCon = new OWriterConnection(this); pCon->construct(url, info); - m_xConnections.emplace_back(*pCon); + m_xConnections.push_back(pCon.get()); return pCon; } diff --git a/connectivity/source/inc/file/FDriver.hxx b/connectivity/source/inc/file/FDriver.hxx index 0351c59ca27a..e48ced409736 100644 --- a/connectivity/source/inc/file/FDriver.hxx +++ b/connectivity/source/inc/file/FDriver.hxx @@ -25,9 +25,12 @@ #include <cppuhelper/compbase.hxx> #include <connectivity/CommonTools.hxx> #include <file/filedllapi.hxx> +#include <unotools/weakref.hxx> namespace connectivity::file { + class OConnection; + typedef ::cppu::WeakComponentImplHelper< css::sdbc::XDriver, css::lang::XServiceInfo, css::sdbcx::XDataDefinitionSupplier> ODriver_BASE; @@ -37,7 +40,7 @@ namespace connectivity::file protected: ::osl::Mutex m_aMutex; - connectivity::OWeakRefArray m_xConnections; // vector containing a list + std::vector<unotools::WeakReference<OConnection>> m_xConnections; // vector containing a list // of all the Connection objects // for this Driver css::uno::Reference< css::uno::XComponentContext > m_xContext;