connectivity/source/drivers/evoab2/NStatement.cxx    |    4 ++--
 connectivity/source/drivers/evoab2/NStatement.hxx    |    5 ++++-
 dbaccess/source/core/dataaccess/ModelImpl.cxx        |   14 +++++++++-----
 dbaccess/source/core/dataaccess/databasedocument.cxx |   15 ++++++++++++++-
 dbaccess/source/core/dataaccess/databasedocument.hxx |    3 +++
 dbaccess/source/core/dataaccess/datasource.cxx       |    4 ++--
 dbaccess/source/core/inc/ModelImpl.hxx               |    6 ++++--
 7 files changed, 38 insertions(+), 13 deletions(-)

New commits:
commit 87039e3e772c7b36480e70019dea0faa15feef6b
Author:     Noel Grandin <[email protected]>
AuthorDate: Fri Sep 20 15:10:22 2024 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Mon Sep 23 18:32:24 2024 +0200

    use more concrete UNO types in dbaccess
    
    Change-Id: I3f689e6ec296fe0c8876ba5cc68133f28902b3fc
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173816
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/dbaccess/source/core/dataaccess/ModelImpl.cxx 
b/dbaccess/source/core/dataaccess/ModelImpl.cxx
index 78f1693ebc97..7c566fc8286d 100644
--- a/dbaccess/source/core/dataaccess/ModelImpl.cxx
+++ b/dbaccess/source/core/dataaccess/ModelImpl.cxx
@@ -624,8 +624,12 @@ void ODatabaseModelImpl::dispose()
     // dispose the data source and the model
     try
     {
-        Reference< XDataSource > xDS( m_xDataSource );
-        ::comphelper::disposeComponent( xDS );
+        rtl::Reference< ODatabaseSource > xDS( m_xDataSource );
+        if (xDS)
+        {
+            xDS->dispose();
+            m_xDataSource.clear();
+        }
 
         Reference< XModel > xModel( m_xModel );
         ::comphelper::disposeComponent( xModel );
@@ -634,7 +638,7 @@ void ODatabaseModelImpl::dispose()
     {
         DBG_UNHANDLED_EXCEPTION("dbaccess");
     }
-    m_xDataSource = WeakReference<XDataSource>();
+    m_xDataSource.clear();
     m_xModel = WeakReference< XModel >();
 
     for (auto const& elem : m_aContainer)
@@ -942,11 +946,11 @@ void ODatabaseModelImpl::setModified( bool _bModified )
 
 Reference<XDataSource> ODatabaseModelImpl::getOrCreateDataSource()
 {
-    Reference<XDataSource> xDs = m_xDataSource;
+    rtl::Reference<ODatabaseSource> xDs = m_xDataSource;
     if ( !xDs.is() )
     {
         xDs = new ODatabaseSource(this);
-        m_xDataSource = xDs;
+        m_xDataSource = xDs.get();
     }
     return xDs;
 }
diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx 
b/dbaccess/source/core/dataaccess/databasedocument.cxx
index 9ece0a1493b4..8ab876fef99b 100644
--- a/dbaccess/source/core/dataaccess/databasedocument.cxx
+++ b/dbaccess/source/core/dataaccess/databasedocument.cxx
@@ -23,6 +23,7 @@
 #include "documenteventexecutor.hxx"
 #include <databasecontext.hxx>
 #include "documentcontainer.hxx"
+#include "commandcontainer.hxx"
 #include <sdbcoretools.hxx>
 #include <strings.hxx>
 #include <recovery/dbdocrecovery.hxx>
@@ -149,7 +150,8 @@ ODatabaseDocument::ODatabaseDocument(const 
::rtl::Reference<ODatabaseModelImpl>&
     {
         impl_reparent_nothrow( m_xForms );
         impl_reparent_nothrow( m_xReports );
-        impl_reparent_nothrow( m_pImpl->m_xTableDefinitions );
+        if (auto xTableDef = m_pImpl->m_xTableDefinitions.get())
+            xTableDef->setParent(*this);
         impl_reparent_nothrow( m_pImpl->m_xCommandDefinitions );
 
         m_pEventExecutor = new DocumentEventExecutor( m_pImpl->m_aContext, 
this );
@@ -1395,6 +1397,17 @@ void ODatabaseDocument::clearObjectContainer( 
WeakReference< XNameAccess >& _rxC
     _rxContainer.clear();
 }
 
+void ODatabaseDocument::clearObjectContainer( unotools::WeakReference< 
OCommandContainer >& _rxContainer)
+{
+    rtl::Reference< OCommandContainer > xContainer = _rxContainer;
+    if ( xContainer.is() )
+    {
+        xContainer->dispose();
+        xContainer->setParent( nullptr );
+    }
+    _rxContainer.clear();
+}
+
 Reference< XNameAccess > ODatabaseDocument::impl_getDocumentContainer_throw( 
ODatabaseModelImpl::ObjectType _eType )
 {
     if ( ( _eType != ODatabaseModelImpl::ObjectType::Form ) && ( _eType != 
ODatabaseModelImpl::ObjectType::Report ) )
diff --git a/dbaccess/source/core/dataaccess/databasedocument.hxx 
b/dbaccess/source/core/dataaccess/databasedocument.hxx
index daccea4d1f9f..46d86d278dc9 100644
--- a/dbaccess/source/core/dataaccess/databasedocument.hxx
+++ b/dbaccess/source/core/dataaccess/databasedocument.hxx
@@ -74,6 +74,7 @@ namespace dbaccess
 class DocumentEvents;
 class DocumentEventExecutor;
 class DocumentGuard;
+class OCommandContainer;
 
 typedef std::vector< css::uno::Reference< css::frame::XController > >   
Controllers;
 
@@ -439,6 +440,8 @@ public:
     */
     static void clearObjectContainer(
                 css::uno::WeakReference< css::container::XNameAccess >& 
_rxContainer);
+    static void clearObjectContainer(
+                unotools::WeakReference< OCommandContainer >& _rxContainer);
 
     /** checks whether the component is already initialized, throws a 
NotInitializedException if not
     */
diff --git a/dbaccess/source/core/dataaccess/datasource.cxx 
b/dbaccess/source/core/dataaccess/datasource.cxx
index f8874911b960..40b248411597 100644
--- a/dbaccess/source/core/dataaccess/datasource.cxx
+++ b/dbaccess/source/core/dataaccess/datasource.cxx
@@ -1200,12 +1200,12 @@ Reference< XNameAccess >  ODatabaseSource::getTables()
 {
     ModelMethodGuard aGuard( *this );
 
-    Reference< XNameAccess > xContainer = m_pImpl->m_xTableDefinitions;
+    rtl::Reference< OCommandContainer > xContainer = 
m_pImpl->m_xTableDefinitions;
     if ( !xContainer.is() )
     {
         TContentPtr& rContainerData( m_pImpl->getObjectContainer( 
ODatabaseModelImpl::ObjectType::Table ) );
         xContainer = new OCommandContainer( m_pImpl->m_aContext, *this, 
rContainerData, true );
-        m_pImpl->m_xTableDefinitions = xContainer;
+        m_pImpl->m_xTableDefinitions = xContainer.get();
     }
     return xContainer;
 }
diff --git a/dbaccess/source/core/inc/ModelImpl.hxx 
b/dbaccess/source/core/inc/ModelImpl.hxx
index 2ddd1889dc2f..92165ea956a9 100644
--- a/dbaccess/source/core/inc/ModelImpl.hxx
+++ b/dbaccess/source/core/inc/ModelImpl.hxx
@@ -44,6 +44,7 @@
 #include <rtl/digest.h>
 #include <rtl/ref.hxx>
 #include <o3tl/enumarray.hxx>
+#include <unotools/weakref.hxx>
 
 #include <span>
 
@@ -54,6 +55,7 @@ namespace comphelper
 
 namespace dbaccess
 {
+class OCommandContainer;
 
 typedef std::vector< css::uno::WeakReference< css::sdbc::XConnection > > 
OWeakConnectionArray;
 
@@ -173,7 +175,7 @@ public:
 
 private:
     css::uno::WeakReference< css::frame::XModel >                     m_xModel;
-    css::uno::WeakReference< css::sdbc::XDataSource >                 
m_xDataSource;
+    unotools::WeakReference< ODatabaseSource >                        
m_xDataSource;
 
     rtl::Reference<DocumentStorageAccess>                             
m_pStorageAccess;
     o3tl::enumarray< ObjectType, TContentPtr >                        
m_aContainer;   // one for each ObjectType
@@ -221,7 +223,7 @@ public:
 
 public:
     css::uno::WeakReference< css::container::XNameAccess >    
m_xCommandDefinitions;
-    css::uno::WeakReference< css::container::XNameAccess >    
m_xTableDefinitions;
+    unotools::WeakReference< ::dbaccess::OCommandContainer > 
m_xTableDefinitions;
 
     css::uno::Reference< css::util::XNumberFormatsSupplier >
                                                               
m_xNumberFormatsSupplier;
commit 5fb48fb349d106bab8f24e042a9fbd92368b06ca
Author:     Noel Grandin <[email protected]>
AuthorDate: Fri Sep 20 14:54:03 2024 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Mon Sep 23 18:32:12 2024 +0200

    use more concrete UNO types in connectivity
    
    Change-Id: I313dae1589d8097d3c9f3c16ae978cdc07d54ebf
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173815
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/connectivity/source/drivers/evoab2/NStatement.cxx 
b/connectivity/source/drivers/evoab2/NStatement.cxx
index 97f5b5833dfe..8fee66699b3d 100644
--- a/connectivity/source/drivers/evoab2/NStatement.cxx
+++ b/connectivity/source/drivers/evoab2/NStatement.cxx
@@ -160,7 +160,7 @@ OCommonStatement::~OCommonStatement()
 void OCommonStatement::disposeResultSet()
 {
     // free the cursor if alive
-    Reference< XComponent > xComp(m_xResultSet.get(), UNO_QUERY);
+    rtl::Reference< OEvoabResultSet > xComp(m_xResultSet);
     if (xComp.is())
         xComp->dispose();
     m_xResultSet.clear();
@@ -613,7 +613,7 @@ Reference< XResultSet > 
OCommonStatement::impl_executeQuery_throw( const QueryDa
     pResult->construct( _rQueryData );
 
     // done
-    m_xResultSet = Reference<XWeak>(pResult);
+    m_xResultSet = pResult.get();
     return pResult;
 }
 
diff --git a/connectivity/source/drivers/evoab2/NStatement.hxx 
b/connectivity/source/drivers/evoab2/NStatement.hxx
index a348c5335d56..02bed5ea318b 100644
--- a/connectivity/source/drivers/evoab2/NStatement.hxx
+++ b/connectivity/source/drivers/evoab2/NStatement.hxx
@@ -36,6 +36,7 @@
 #include <com/sun/star/util/XCancellable.hpp>
 #include <cppuhelper/compbase.hxx>
 #include <comphelper/propertycontainer.hxx>
+#include <unotools/weakref.hxx>
 
 #include "EApi.h"
 #include "NConnection.hxx"
@@ -44,6 +45,8 @@
 
 namespace connectivity::evoab
 {
+        class OEvoabResultSet;
+
         typedef ::cppu::WeakComponentImplHelper<   css::sdbc::XWarningsSupplier
                                                ,   css::sdbc::XCloseable
                                                >   OCommonStatement_IBase;
@@ -149,7 +152,7 @@ namespace connectivity::evoab
                                 ,public 
::comphelper::OPropertyArrayUsageHelper< OCommonStatement >
         {
         private:
-            css::uno::WeakReference< css::sdbc::XResultSet>    m_xResultSet;   
// The last ResultSet created
+            unotools::WeakReference< OEvoabResultSet> m_xResultSet;   // The 
last ResultSet created
             rtl::Reference<OEvoabConnection>      m_xConnection;
             connectivity::OSQLParser              m_aParser;
             connectivity::OSQLParseTreeIterator   m_aSQLIterator;

Reply via email to