svx/source/unodraw/unoshcol.cxx |   62 ++++++++++++++++------------------------
 1 file changed, 25 insertions(+), 37 deletions(-)

New commits:
commit 16569ed32638464b4b6857fc2c29f59a919baed7
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Wed Oct 2 19:46:27 2024 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu Oct 3 15:46:47 2024 +0200

    simplify SvxShapeCollection::dispose
    
    Change-Id: Idb1605b27995cbf9eccb2710f74f6ccb37547646
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174409
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Tested-by: Jenkins

diff --git a/svx/source/unodraw/unoshcol.cxx b/svx/source/unodraw/unoshcol.cxx
index 3a58ab514ff3..280dd23f98cf 100644
--- a/svx/source/unodraw/unoshcol.cxx
+++ b/svx/source/unodraw/unoshcol.cxx
@@ -76,52 +76,40 @@ void SvxShapeCollection::dispose()
 
     // Guard dispose against multiple threading
     // Remark: It is an error to call dispose more than once
-    bool bDoDispose = false;
     {
         std::unique_lock aGuard( m_aMutex );
-        if( !bDisposed && !bInDispose )
-        {
-            // only one call go into this section
-            bInDispose = true;
-            bDoDispose = true;
-        }
+        if( bDisposed || bInDispose )
+            return;
+        // only one call go into this section
+        bInDispose = true;
     }
 
     // Do not hold the mutex because we are broadcasting
-    if( bDoDispose )
+    // Create an event with this as sender
+    try
     {
-        // Create an event with this as sender
-        try
-        {
-            document::EventObject aEvt;
-            aEvt.Source = uno::Reference< uno::XInterface >::query( 
static_cast<lang::XComponent *>(this) );
-            // inform all listeners to release this object
-            // The listener container are automatically cleared
-            std::unique_lock g(m_aMutex);
-            maEventListeners.disposeAndClear( g, aEvt );
-            maShapeContainer.clear();
-        }
-        catch(const css::uno::Exception&)
-        {
-            // catch exception and throw again but signal that
-            // the object was disposed. Dispose should be called
-            // only once.
-            bDisposed = true;
-            bInDispose = false;
-            throw;
-        }
-
-        // the values bDispose and bInDisposing must set in this order.
-        // No multithread call overcome the "!rBHelper.bDisposed && 
!rBHelper.bInDispose" guard.
-        bDisposed = true;
-        bInDispose = false;
+        document::EventObject aEvt;
+        aEvt.Source = uno::Reference< uno::XInterface >::query( 
static_cast<lang::XComponent *>(this) );
+        // inform all listeners to release this object
+        // The listener container are automatically cleared
+        std::unique_lock g(m_aMutex);
+        maEventListeners.disposeAndClear( g, aEvt );
+        maShapeContainer.clear();
     }
-    else
+    catch(const css::uno::Exception&)
     {
-        // in a multithreaded environment, it can't be avoided, that dispose 
is called twice.
-        // However this condition is traced, because it MAY indicate an error.
-        SAL_INFO("svx", "dispose called twice" );
+        // catch exception and throw again but signal that
+        // the object was disposed. Dispose should be called
+        // only once.
+        bDisposed = true;
+        bInDispose = false;
+        throw;
     }
+
+    // the values bDispose and bInDisposing must set in this order.
+    // No multithread call overcome the "!rBHelper.bDisposed && 
!rBHelper.bInDispose" guard.
+    bDisposed = true;
+    bInDispose = false;
 }
 
 // XComponent

Reply via email to