connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx |    3 
 connectivity/source/drivers/hsqldb/HDriver.cxx                 |   45 
++++------
 connectivity/source/inc/FDatabaseMetaDataResultSet.hxx         |    1 
 connectivity/source/inc/hsqldb/HDriver.hxx                     |   19 ++--
 4 files changed, 35 insertions(+), 33 deletions(-)

New commits:
commit 90351ca6b1d6483590878bdc55be2b446019ee7c
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Mar 4 11:04:35 2025 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Mar 4 19:34:28 2025 +0100

    ODatabaseMetaDataResultSet::m_aStatement is unused
    
    Change-Id: If8ce23440a5046c8d6b16558ac7ecd885afc0305
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182465
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Jenkins

diff --git a/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx 
b/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx
index 0e490e3b66ad..b2f7f8d86e51 100644
--- a/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx
+++ b/connectivity/source/commontools/FDatabaseMetaDataResultSet.cxx
@@ -106,7 +106,6 @@ void 
ODatabaseMetaDataResultSet::disposing(std::unique_lock<std::mutex>& rGuard)
 {
     OPropertySetHelper::disposing(rGuard);
 
-    m_aStatement.clear();
     m_xMetaData.clear();
     m_aRowsIter = m_aRows.end();
     m_aRows.clear();
@@ -371,7 +370,7 @@ sal_Bool SAL_CALL ODatabaseMetaDataResultSet::previous(  )
 
 Reference< XInterface > SAL_CALL ODatabaseMetaDataResultSet::getStatement(  )
 {
-    return m_aStatement.get();
+    return nullptr;
 }
 
 sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowDeleted(  )
diff --git a/connectivity/source/inc/FDatabaseMetaDataResultSet.hxx 
b/connectivity/source/inc/FDatabaseMetaDataResultSet.hxx
index 28c504ee416b..6dcd7a199daf 100644
--- a/connectivity/source/inc/FDatabaseMetaDataResultSet.hxx
+++ b/connectivity/source/inc/FDatabaseMetaDataResultSet.hxx
@@ -107,7 +107,6 @@ namespace connectivity
 
     private:
         ORowSetValue                    m_aEmptyValue;
-        css::uno::WeakReferenceHelper    m_aStatement;
         rtl::Reference< ODatabaseMetaDataResultSetMetaData>        m_xMetaData;
         sal_Int32                       m_nColPos;
 
commit 52249ad398d64fb982281655edb3b83d1aa4eaed
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Tue Mar 4 10:41:34 2025 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Mar 4 19:34:19 2025 +0100

    improve type safety in hsqldb::ODriverDelegator
    
    we can use type-safe WeakReference wrappers classes. Also use
    a custom struct instead of std::pair<std::pair<
    
    Change-Id: Idc984e316dd063a3656688872bf7b40ca8733b0e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182460
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/connectivity/source/drivers/hsqldb/HDriver.cxx 
b/connectivity/source/drivers/hsqldb/HDriver.cxx
index fa06af4d24bd..91cab732fcee 100644
--- a/connectivity/source/drivers/hsqldb/HDriver.cxx
+++ b/connectivity/source/drivers/hsqldb/HDriver.cxx
@@ -102,7 +102,7 @@ namespace connectivity
         {
             for (const auto& rConnection : m_aConnections)
             {
-                Reference<XInterface > xTemp = rConnection.first.get();
+                Reference<XConnection> xTemp(rConnection.xOrigConn);
                 ::comphelper::disposeComponent(xTemp);
             }
         }
@@ -111,7 +111,6 @@ namespace connectivity
             // not interested in
         }
         m_aConnections.clear();
-        TWeakPairVector().swap(m_aConnections);
 
         cppu::WeakComponentImplHelperBase::disposing();
     }
@@ -380,7 +379,7 @@ namespace connectivity
                     }();
                     Reference< XComponent> xIfc = new OHsqlConnection( this, 
xOrig, m_xContext );
                     xConnection.set(xIfc,UNO_QUERY);
-                    
m_aConnections.push_back(TWeakPair(WeakReferenceHelper(xOrig),TWeakConnectionPair(sKey,TWeakRefPair(WeakReferenceHelper(xConnection),WeakReferenceHelper()))));
+                    m_aConnections.push_back( { xOrig, sKey, xConnection, 
nullptr } );
 
                     Reference<XTransactionBroadcaster> 
xBroad(xStorage,UNO_QUERY);
                     if ( xBroad.is() )
@@ -464,18 +463,18 @@ namespace connectivity
         ::osl::MutexGuard aGuard( m_aMutex );
         checkDisposed(ODriverDelegator_BASE::rBHelper.bDisposed);
 
-        Reference< XTablesSupplier > xTab;
+        rtl::Reference< OHCatalog > xTab;
 
-        TWeakPairVector::iterator i = std::find_if(m_aConnections.begin(), 
m_aConnections.end(),
-            [&connection](const TWeakPairVector::value_type& rConnection) {
-                return rConnection.second.second.first.get() == 
connection.get(); });
+        auto i = std::find_if(m_aConnections.begin(), m_aConnections.end(),
+            [&connection](const TConnectionInfo& rConnection) {
+                return rConnection.xConn.get() == connection.get(); });
         if (i != m_aConnections.end())
         {
-            xTab.set(i->second.second.second,UNO_QUERY);
+            xTab = i->xCatalog.get();
             if ( !xTab.is() )
             {
                 xTab = new OHCatalog(connection);
-                i->second.second.second = WeakReferenceHelper(xTab);
+                i->xCatalog = xTab.get();
             }
         }
 
@@ -517,13 +516,13 @@ namespace connectivity
         ::dbtools::throwFeatureNotImplementedSQLException( 
u"XCreateCatalog::createCatalog"_ustr, *this );
     }
 
-    void ODriverDelegator::shutdownConnection(const TWeakPairVector::iterator& 
_aIter )
+    void ODriverDelegator::shutdownConnection(const 
std::vector<TConnectionInfo>::iterator& _aIter )
     {
         OSL_ENSURE(m_aConnections.end() != _aIter,"Iterator equals .end()");
         bool bLastOne = true;
         try
         {
-            Reference<XConnection> _xConnection(_aIter->first.get(),UNO_QUERY);
+            Reference<XConnection> _xConnection(_aIter->xOrigConn);
 
             if ( _xConnection.is() )
             {
@@ -546,7 +545,7 @@ namespace connectivity
         {
             // Reference<XTransactionListener> xListener(*this,UNO_QUERY);
             // a shutdown should commit all changes to the db files
-            StorageContainer::revokeStorage(_aIter->second.first,nullptr);
+            StorageContainer::revokeStorage(_aIter->sKey,nullptr);
         }
         if ( !m_bInShutDownConnections )
             m_aConnections.erase(_aIter);
@@ -558,8 +557,8 @@ namespace connectivity
         Reference<XConnection> xCon(Source.Source,UNO_QUERY);
         if ( xCon.is() )
         {
-            TWeakPairVector::iterator i = std::find_if(m_aConnections.begin(), 
m_aConnections.end(),
-                [&xCon](const TWeakPairVector::value_type& rConnection) { 
return rConnection.first.get() == xCon.get(); });
+            auto i = std::find_if(m_aConnections.begin(), m_aConnections.end(),
+                [&xCon](const TConnectionInfo& rConnection) { return 
rConnection.xOrigConn.get() == xCon.get(); });
 
             if (i != m_aConnections.end())
                 shutdownConnection(i);
@@ -570,9 +569,9 @@ namespace connectivity
             if ( xStorage.is() )
             {
                 OUString sKey = StorageContainer::getRegisteredKey(xStorage);
-                TWeakPairVector::iterator i = 
std::find_if(m_aConnections.begin(),m_aConnections.end(),
-                    [&sKey] (const TWeakPairVector::value_type& conn) {
-                        return conn.second.first == sKey;
+                auto i = 
std::find_if(m_aConnections.begin(),m_aConnections.end(),
+                    [&sKey] (const TConnectionInfo& conn) {
+                        return conn.sKey == sKey;
                     });
 
                 if ( i != m_aConnections.end() )
@@ -588,7 +587,7 @@ namespace connectivity
         {
             try
             {
-                Reference<XConnection> xCon(rConnection.first,UNO_QUERY);
+                Reference<XConnection> xCon(rConnection.xOrigConn);
                 ::comphelper::disposeComponent(xCon);
             }
             catch(Exception&)
@@ -605,7 +604,7 @@ namespace connectivity
         {
             try
             {
-                Reference<XFlushable> 
xCon(rConnection.second.second.first.get(),UNO_QUERY);
+                Reference<XFlushable> xCon(rConnection.xConn.get(),UNO_QUERY);
                 if (xCon.is())
                     xCon->flush();
             }
@@ -625,9 +624,9 @@ namespace connectivity
         if ( sKey.isEmpty() )
             return;
 
-        TWeakPairVector::const_iterator i = 
std::find_if(m_aConnections.begin(), m_aConnections.end(),
-            [&sKey] (const TWeakPairVector::value_type& conn) {
-                return conn.second.first == sKey;
+        auto i = std::find_if(m_aConnections.begin(), m_aConnections.end(),
+            [&sKey] (const TConnectionInfo& conn) {
+                return conn.sKey == sKey;
             });
 
         OSL_ENSURE( i != m_aConnections.end(), "ODriverDelegator::preCommit: 
they're committing a storage which I do not know!" );
@@ -636,7 +635,7 @@ namespace connectivity
 
         try
         {
-            Reference<XConnection> xConnection(i->first,UNO_QUERY);
+            Reference<XConnection> xConnection(i->xOrigConn);
             if ( xConnection.is() )
             {
                 Reference< XStatement> xStmt = xConnection->createStatement();
diff --git a/connectivity/source/inc/hsqldb/HDriver.hxx 
b/connectivity/source/inc/hsqldb/HDriver.hxx
index 0dda7e5e0fa2..8ea41aaa12d6 100644
--- a/connectivity/source/inc/hsqldb/HDriver.hxx
+++ b/connectivity/source/inc/hsqldb/HDriver.hxx
@@ -27,10 +27,13 @@
 #include <cppuhelper/compbase.hxx>
 #include <cppuhelper/basemutex.hxx>
 #include <connectivity/CommonTools.hxx>
+#include <unotools/weakref.hxx>
 
 
 namespace connectivity::hsqldb
     {
+        class OHCatalog;
+
         typedef ::cppu::WeakComponentImplHelper<   css::sdbc::XDriver
                                                  , 
css::sdbcx::XDataDefinitionSupplier
                                                  , css::lang::XServiceInfo
@@ -38,11 +41,13 @@ namespace connectivity::hsqldb
                                                  , 
css::embed::XTransactionListener
                                                >   ODriverDelegator_BASE;
 
-        typedef std::pair< 
css::uno::WeakReferenceHelper,css::uno::WeakReferenceHelper> TWeakRefPair;
-        typedef std::pair< OUString ,TWeakRefPair > TWeakConnectionPair;
-
-        typedef std::pair< css::uno::WeakReferenceHelper,TWeakConnectionPair> 
TWeakPair;
-        typedef std::vector< TWeakPair > TWeakPairVector;
+        struct TConnectionInfo
+        {
+            css::uno::WeakReference<css::sdbc::XConnection> xOrigConn;
+            OUString sKey;
+            css::uno::WeakReference<css::sdbc::XConnection> xConn;
+            unotools::WeakReference<OHCatalog> xCatalog;
+        };
 
 
         /** delegates all calls to the original driver and extend the existing 
one with the SDBCX layer.
@@ -51,7 +56,7 @@ namespace connectivity::hsqldb
         class ODriverDelegator final : public ::cppu::BaseMutex
                                 ,public ODriverDelegator_BASE
         {
-            TWeakPairVector                                           
m_aConnections; //  vector containing a list
+            std::vector<TConnectionInfo>                              
m_aConnections; //  vector containing a list
                                                                                
       //  of all the Connection objects
                                                                                
       //  for this Driver
             css::uno::Reference< css::sdbc::XDriver >                 
m_xDriver;
@@ -69,7 +74,7 @@ namespace connectivity::hsqldb
                 @param  _aIter
                     The connection to shut down and storage to revoke.
             */
-            void shutdownConnection(const TWeakPairVector::iterator& _aIter);
+            void shutdownConnection(const 
std::vector<TConnectionInfo>::iterator& _aIter);
 
         public:
             /** creates a new delegator for a HSQLDB driver

Reply via email to