connectivity/source/drivers/mysqlc/mysqlc_connection.cxx | 10 +++++----- connectivity/source/drivers/mysqlc/mysqlc_connection.hxx | 10 +++++----- connectivity/source/drivers/mysqlc/mysqlc_driver.hxx | 2 ++ connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx | 6 +++--- connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.hxx | 2 +- 5 files changed, 16 insertions(+), 14 deletions(-)
New commits: commit ab9ba059a6a990dc581520387f0cde6e406a8783 Author: Noel Grandin <[email protected]> AuthorDate: Tue Mar 4 13:29:46 2025 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Tue Mar 4 20:29:59 2025 +0100 improve type safety in mysqlc::OConnection Change-Id: Id41f78a67c9634ddfcfd0435357bb9a754a150f9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182475 Tested-by: Jenkins Reviewed-by: Noel Grandin <[email protected]> diff --git a/connectivity/source/drivers/mysqlc/mysqlc_connection.cxx b/connectivity/source/drivers/mysqlc/mysqlc_connection.cxx index 035b373b69cd..631208f70293 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_connection.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_connection.cxx @@ -218,8 +218,8 @@ Reference<XStatement> SAL_CALL OConnection::createStatement() // create a statement // the statement can only be executed once - Reference<XStatement> xReturn = new OStatement(this); - m_aStatements.push_back(WeakReferenceHelper(xReturn)); + rtl::Reference<OStatement> xReturn = new OStatement(this); + m_aStatements.push_back(xReturn.get()); return xReturn; } @@ -240,8 +240,8 @@ Reference<XPreparedStatement> SAL_CALL OConnection::prepareStatement(const OUStr mysql_sqlstate(&m_mysql), nErrorNum, *this, getConnectionEncoding()); - Reference<XPreparedStatement> xStatement = new OPreparedStatement(this, pStmt); - m_aStatements.push_back(WeakReferenceHelper(xStatement)); + rtl::Reference<OPreparedStatement> xStatement = new OPreparedStatement(this, pStmt); + m_aStatements.push_back(xStatement.get()); return xStatement; } @@ -432,7 +432,7 @@ void OConnection::disposing() for (auto const& statement : m_aStatements) { - Reference<XComponent> xComp(statement.get(), UNO_QUERY); + rtl::Reference<OCommonStatement> xComp(statement.get()); if (xComp.is()) { xComp->dispose(); diff --git a/connectivity/source/drivers/mysqlc/mysqlc_connection.hxx b/connectivity/source/drivers/mysqlc/mysqlc_connection.hxx index 3a0ccf36b4ed..dd7138fff464 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_connection.hxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_connection.hxx @@ -37,6 +37,7 @@ #include <cppuhelper/basemutex.hxx> #include <cppuhelper/compbase.hxx> #include <rtl/ref.hxx> +#include <unotools/weakref.hxx> #include <mysql.h> @@ -54,6 +55,8 @@ class ODatabaseMetaData; namespace mysqlc { +class OCommonStatement; + typedef ::cppu::WeakComponentImplHelper<css::sdbc::XConnection, css::sdbc::XWarningsSupplier, css::lang::XUnoTunnel, css::lang::XServiceInfo> OMetaConnection_BASE; @@ -74,8 +77,6 @@ class MysqlCDriver; typedef OMetaConnection_BASE OConnection_BASE; -typedef std::vector<css::uno::WeakReferenceHelper> OWeakRefArray; - class OConnection final : public cppu::BaseMutex, public OConnection_BASE { private: @@ -89,9 +90,8 @@ private: css::uno::WeakReference<css::sdbcx::XTablesSupplier> m_xCatalog; css::uno::WeakReference<css::sdbc::XDatabaseMetaData> m_xMetaData; - OWeakRefArray m_aStatements; // vector containing a list - // of all the Statement objects - // for this Connection + // vector containing a list of all the Statement objects for this Connection. + std::vector<unotools::WeakReference<OCommonStatement>> m_aStatements; rtl::Reference<MysqlCDriver> m_xDriver; // Pointer to the owning driver object public: diff --git a/connectivity/source/drivers/mysqlc/mysqlc_driver.hxx b/connectivity/source/drivers/mysqlc/mysqlc_driver.hxx index a29040892577..0ed02d0b18e5 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_driver.hxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_driver.hxx @@ -30,6 +30,8 @@ namespace connectivity::mysqlc using css::uno::Reference; using css::uno::Sequence; +typedef std::vector<css::uno::WeakReferenceHelper> OWeakRefArray; + Reference<css::uno::XInterface> MysqlCDriver_CreateInstance(const Reference<css::lang::XMultiServiceFactory>& _rxFactory); commit 773fa222432cd8191d3155cfa7608f7ba516f947 Author: Noel Grandin <[email protected]> AuthorDate: Tue Mar 4 13:23:31 2025 +0200 Commit: Noel Grandin <[email protected]> CommitDate: Tue Mar 4 20:29:51 2025 +0100 improve type safety in mysqlc::OPreparedResultSet Change-Id: If0a427ff5c02ed15f62608603e641a8f6dbe5755 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182474 Reviewed-by: Noel Grandin <[email protected]> Tested-by: Jenkins diff --git a/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx b/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx index d8bfbe5f9892..6fd5d67823d5 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.cxx @@ -180,7 +180,7 @@ OPreparedResultSet::OPreparedResultSet(OConnection& rConn, OPreparedStatement* p : OPreparedResultSet_BASE(m_aMutex) , OPropertySetHelper(OPreparedResultSet_BASE::rBHelper) , m_rConnection(rConn) - , m_aStatement(css::uno::Reference(cppu::getXWeak(pStmt))) + , m_xStatement(pStmt) , m_pStmt(pMyStmt) , m_encoding(rConn.getConnectionEncoding()) , m_nColumnCount(mysql_stmt_field_count(pMyStmt)) @@ -198,7 +198,7 @@ void OPreparedResultSet::disposing() MutexGuard aGuard(m_aMutex); - m_aStatement.clear(); + m_xStatement.clear(); m_xMetaData = nullptr; } @@ -689,7 +689,7 @@ uno::Reference<uno::XInterface> SAL_CALL OPreparedResultSet::getStatement() MutexGuard aGuard(m_aMutex); checkDisposed(OPreparedResultSet_BASE::rBHelper.bDisposed); - return m_aStatement.get(); + return cppu::getXWeak(m_xStatement.get().get()); } sal_Bool SAL_CALL OPreparedResultSet::rowDeleted() diff --git a/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.hxx b/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.hxx index 4374fc7ad091..3f79ddcd1e73 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.hxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_prepared_resultset.hxx @@ -56,7 +56,7 @@ class OPreparedResultSet final : public cppu::BaseMutex, public OPropertyArrayUsageHelper<OPreparedResultSet> { OConnection& m_rConnection; - css::uno::WeakReferenceHelper m_aStatement; + unotools::WeakReference<OPreparedStatement> m_xStatement; rtl::Reference<OResultSetMetaData> m_xMetaData; // non-owning pointers
