chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx |    3 +--
 connectivity/source/drivers/firebird/Statement.cxx                |    3 ++-
 connectivity/source/sdbcx/VColumn.cxx                             |    4 ----
 dbaccess/source/core/api/RowSet.cxx                               |    2 +-
 framework/source/uielement/buttontoolbarcontroller.cxx            |    2 +-
 framework/source/uielement/statusbarwrapper.cxx                   |    2 +-
 package/source/xstor/ocompinstream.cxx                            |   10 
++--------
 package/source/xstor/xstorage.cxx                                 |   10 
++--------
 sot/source/unoolestorage/xolesimplestorage.cxx                    |    2 +-
 svl/source/fsstor/oinputstreamcontainer.cxx                       |    2 +-
 svl/source/fsstor/ostreamcontainer.cxx                            |    2 +-
 svtools/source/uno/framestatuslistener.cxx                        |    2 +-
 svtools/source/uno/statusbarcontroller.cxx                        |    2 +-
 svtools/source/uno/toolboxcontroller.cxx                          |    2 +-
 toolkit/source/hatchwindow/documentcloser.cxx                     |    2 +-
 15 files changed, 17 insertions(+), 33 deletions(-)

New commits:
commit 009b889616561176a230bc041699271697f95bf6
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed May 31 15:31:36 2023 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed May 31 18:37:34 2023 +0200

    do not throw DisposedException when inside a dispose() method
    
    There is no need to do this, as the documentation of
    css.lang.XComponent::dispose at
    
        udkapi/com/sun/star/lang/XComponent.idl
    
    states:
    
        After this method has been called, the object should
        behave as passive as possible, thus it should ignore all calls
    
    Otherwise, the effect of throwing here is mostly to disturb the flow of
    logic in caller code, preventing other parts of teardown from proceeding
    smoothly.
    
    Change-Id: I30e6d1b35f85b727debf4405a995fdc0a4fccde6
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152450
    Tested-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx 
b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
index 5c27adcbfc18..85ff5c7022c3 100644
--- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
+++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx
@@ -855,8 +855,7 @@ Reference< uno::XInterface > SAL_CALL 
ChartDocumentWrapper::getCurrentSelection(
 void SAL_CALL ChartDocumentWrapper::dispose()
 {
     if( m_bIsDisposed )
-        throw lang::DisposedException("ChartDocumentWrapper is disposed",
-            static_cast< ::cppu::OWeakObject* >( this ));
+        return;
 
     m_bIsDisposed = true;
 
diff --git a/connectivity/source/drivers/firebird/Statement.cxx 
b/connectivity/source/drivers/firebird/Statement.cxx
index 5d9abdf2ef78..d135c4e4cda4 100644
--- a/connectivity/source/drivers/firebird/Statement.cxx
+++ b/connectivity/source/drivers/firebird/Statement.cxx
@@ -70,7 +70,8 @@ void SAL_CALL OStatement::release() noexcept
 void OStatement::disposeResultSet()
 {
     MutexGuard aGuard(m_aMutex);
-    checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
+    if (OStatementCommonBase_Base::rBHelper.bDisposed)
+        return;
 
     OStatementCommonBase::disposeResultSet();
 
diff --git a/connectivity/source/sdbcx/VColumn.cxx 
b/connectivity/source/sdbcx/VColumn.cxx
index a61d0619a6e3..ad9a52ed12ed 100644
--- a/connectivity/source/sdbcx/VColumn.cxx
+++ b/connectivity/source/sdbcx/VColumn.cxx
@@ -170,10 +170,6 @@ void OColumn::construct()
 void OColumn::disposing()
 {
     OPropertySetHelper::disposing();
-
-    ::osl::MutexGuard aGuard(m_aMutex);
-    checkDisposed(OColumnDescriptor_BASE::rBHelper.bDisposed);
-
 }
 
 Reference< XPropertySet > SAL_CALL OColumn::createDataDescriptor(  )
diff --git a/dbaccess/source/core/api/RowSet.cxx 
b/dbaccess/source/core/api/RowSet.cxx
index b6d73a0d4869..ec4edf6f0fb4 100644
--- a/dbaccess/source/core/api/RowSet.cxx
+++ b/dbaccess/source/core/api/RowSet.cxx
@@ -2872,7 +2872,7 @@ void ORowSetClone::close()
     {
         MutexGuard aGuard( m_aMutex );
         if (WeakComponentImplHelper::rBHelper.bDisposed)
-            throw DisposedException();
+            return;
     }
     dispose();
 }
diff --git a/framework/source/uielement/buttontoolbarcontroller.cxx 
b/framework/source/uielement/buttontoolbarcontroller.cxx
index d94e5b0ff25f..d100ee17113e 100644
--- a/framework/source/uielement/buttontoolbarcontroller.cxx
+++ b/framework/source/uielement/buttontoolbarcontroller.cxx
@@ -126,7 +126,7 @@ void SAL_CALL ButtonToolbarController::dispose()
     {
         SolarMutexGuard aSolarMutexGuard;
         if ( m_bDisposed )
-            throw DisposedException();
+            return;
 
         m_xContext.clear();
         m_xURLTransformer.clear();
diff --git a/framework/source/uielement/statusbarwrapper.cxx 
b/framework/source/uielement/statusbarwrapper.cxx
index 7627b2f0a110..8ce6e48e5eb1 100644
--- a/framework/source/uielement/statusbarwrapper.cxx
+++ b/framework/source/uielement/statusbarwrapper.cxx
@@ -61,7 +61,7 @@ void SAL_CALL StatusBarWrapper::dispose()
 
     SolarMutexGuard g;
     if ( m_bDisposed )
-        throw DisposedException();
+        return;
 
     if ( m_xStatusBarManager.is() )
         m_xStatusBarManager->dispose();
diff --git a/package/source/xstor/ocompinstream.cxx 
b/package/source/xstor/ocompinstream.cxx
index ef6bea3e8b06..b5931c0c0918 100644
--- a/package/source/xstor/ocompinstream.cxx
+++ b/package/source/xstor/ocompinstream.cxx
@@ -185,10 +185,7 @@ void OInputCompStream::InternalDispose()
     // can be called only by OWriteStream_Impl
     ::osl::MutexGuard aGuard( m_xMutex->GetMutex() );
     if ( m_bDisposed )
-    {
-        SAL_INFO("package.xstor", "Disposed!");
-        throw lang::DisposedException();
-    }
+        return;
 
     // the source object is also a kind of locker for the current object
     // since the listeners could dispose the object while being notified
@@ -212,10 +209,7 @@ void SAL_CALL OInputCompStream::dispose(  )
 {
     ::osl::MutexGuard aGuard( m_xMutex->GetMutex() );
     if ( m_bDisposed )
-    {
-        SAL_INFO("package.xstor", "Disposed!");
-        throw lang::DisposedException();
-    }
+        return;
 
     if ( m_pInterfaceContainer )
     {
diff --git a/package/source/xstor/xstorage.cxx 
b/package/source/xstor/xstorage.cxx
index f94a9fbdf9b5..6e22a853c18f 100644
--- a/package/source/xstor/xstorage.cxx
+++ b/package/source/xstor/xstorage.cxx
@@ -1792,10 +1792,7 @@ OStorage::~OStorage()
 void OStorage::InternalDispose( bool bNotifyImpl )
 {
     if ( !m_pImpl )
-    {
-        SAL_INFO("package.xstor", THROW_WHERE "Disposed!");
-        throw lang::DisposedException( THROW_WHERE );
-    }
+        return;
 
     // the source object is also a kind of locker for the current object
     // since the listeners could dispose the object while being notified
@@ -1803,10 +1800,7 @@ void OStorage::InternalDispose( bool bNotifyImpl )
     m_aListenersContainer.disposeAndClear( aSource );
 
     if ( !m_pImpl )
-    {
-        SAL_INFO("package.xstor", THROW_WHERE "Disposed!");
-        throw lang::DisposedException( THROW_WHERE );
-    }
+        return;
 
     m_pImpl->m_nModifiedListenerCount = 0;
 
diff --git a/sot/source/unoolestorage/xolesimplestorage.cxx 
b/sot/source/unoolestorage/xolesimplestorage.cxx
index d2cb93a04647..46b82b2b538e 100644
--- a/sot/source/unoolestorage/xolesimplestorage.cxx
+++ b/sot/source/unoolestorage/xolesimplestorage.cxx
@@ -546,7 +546,7 @@ void SAL_CALL OLESimpleStorage::dispose()
     std::unique_lock aGuard( m_aMutex );
 
     if ( m_bDisposed )
-        throw lang::DisposedException();
+        return;
 
     if ( m_aListenersContainer.getLength(aGuard) )
     {
diff --git a/svl/source/fsstor/oinputstreamcontainer.cxx 
b/svl/source/fsstor/oinputstreamcontainer.cxx
index f6481b76ff28..9c4caaea2e58 100644
--- a/svl/source/fsstor/oinputstreamcontainer.cxx
+++ b/svl/source/fsstor/oinputstreamcontainer.cxx
@@ -223,7 +223,7 @@ void SAL_CALL OFSInputStreamContainer::dispose(  )
     std::unique_lock aGuard( m_aMutex );
 
     if ( m_bDisposed )
-        throw lang::DisposedException();
+        return;
 
     if ( !m_xInputStream.is() )
         throw uno::RuntimeException();
diff --git a/svl/source/fsstor/ostreamcontainer.cxx 
b/svl/source/fsstor/ostreamcontainer.cxx
index e02ce1383df9..744d9ce5cfe1 100644
--- a/svl/source/fsstor/ostreamcontainer.cxx
+++ b/svl/source/fsstor/ostreamcontainer.cxx
@@ -208,7 +208,7 @@ void SAL_CALL OFSStreamContainer::dispose()
     std::unique_lock aGuard( m_aMutex );
 
     if ( m_bDisposed )
-        throw lang::DisposedException();
+        return;
 
     if ( !m_xStream.is() )
         throw uno::RuntimeException();
diff --git a/svtools/source/uno/framestatuslistener.cxx 
b/svtools/source/uno/framestatuslistener.cxx
index 25152f2f3b4a..166433dff1b9 100644
--- a/svtools/source/uno/framestatuslistener.cxx
+++ b/svtools/source/uno/framestatuslistener.cxx
@@ -83,7 +83,7 @@ void SAL_CALL FrameStatusListener::dispose()
 
     SolarMutexGuard aSolarMutexGuard;
     if ( m_bDisposed )
-        throw DisposedException();
+        return;
 
     for (auto const& listener : m_aListenerMap)
     {
diff --git a/svtools/source/uno/statusbarcontroller.cxx 
b/svtools/source/uno/statusbarcontroller.cxx
index 6a8499a353c7..7ab3a2e29c40 100644
--- a/svtools/source/uno/statusbarcontroller.cxx
+++ b/svtools/source/uno/statusbarcontroller.cxx
@@ -179,7 +179,7 @@ void SAL_CALL StatusbarController::dispose()
     {
         SolarMutexGuard aSolarMutexGuard;
         if ( m_bDisposed )
-            throw DisposedException();
+            return;
     }
 
     css::lang::EventObject aEvent( xThis );
diff --git a/svtools/source/uno/toolboxcontroller.cxx 
b/svtools/source/uno/toolboxcontroller.cxx
index b592bb25b859..4c9611ff7dba 100644
--- a/svtools/source/uno/toolboxcontroller.cxx
+++ b/svtools/source/uno/toolboxcontroller.cxx
@@ -243,7 +243,7 @@ void SAL_CALL ToolboxController::dispose()
     {
         SolarMutexGuard aSolarMutexGuard;
         if ( m_bDisposed )
-            throw DisposedException();
+            return;
     }
 
     css::lang::EventObject aEvent( xThis );
diff --git a/toolkit/source/hatchwindow/documentcloser.cxx 
b/toolkit/source/hatchwindow/documentcloser.cxx
index 800703baa59b..6ef68a6a8845 100644
--- a/toolkit/source/hatchwindow/documentcloser.cxx
+++ b/toolkit/source/hatchwindow/documentcloser.cxx
@@ -167,7 +167,7 @@ void SAL_CALL ODocumentCloser::dispose()
     std::unique_lock aGuard( m_aMutex );
 
     if ( m_bDisposed )
-        throw lang::DisposedException();
+        return;
 
     lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >(this) );
     m_aListenersContainer.disposeAndClear( aGuard, aSource );

Reply via email to