[Libreoffice-commits] core.git: comphelper/source cppuhelper/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Sun Jan 26 07:01:30 UTC 2020


 comphelper/source/container/interfacecontainer2.cxx |   13 ++++++-------
 cppuhelper/source/interfacecontainer.cxx            |   13 ++++++-------
 2 files changed, 12 insertions(+), 14 deletions(-)

New commits:
commit de60c73db31ec34ffb2e008829083bb7ddcb3061
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Sat Jan 25 17:41:43 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Sun Jan 26 08:00:59 2020 +0100

    simplify InterfaceContainerHelper::clear
    
    instead of relying on side-effects from instantiating an iterator
    
    Change-Id: Ie66b9e7ceeb3c4a0f4243fdd0a5ac37af77e98ab
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87412
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/comphelper/source/container/interfacecontainer2.cxx b/comphelper/source/container/interfacecontainer2.cxx
index 36141f7a7e19..1524600affd0 100644
--- a/comphelper/source/container/interfacecontainer2.cxx
+++ b/comphelper/source/container/interfacecontainer2.cxx
@@ -271,18 +271,17 @@ void OInterfaceContainerHelper2::disposeAndClear( const EventObject & rEvt )
 
 void OInterfaceContainerHelper2::clear()
 {
-    ClearableMutexGuard aGuard( rMutex );
-    OInterfaceIteratorHelper2 aIt( *this );
+    MutexGuard aGuard( rMutex );
     // Release container, in case new entries come while disposing
     OSL_ENSURE( !bIsList || bInUse, "OInterfaceContainerHelper2 not in use" );
-    if( !bIsList && aData.pAsInterface )
+    if (bInUse)
+        copyAndResetInUse();
+    if (bIsList)
+        delete aData.pAsVector;
+    else if (aData.pAsInterface)
         aData.pAsInterface->release();
-    // set the member to null, use the iterator to delete the values
     aData.pAsInterface = nullptr;
     bIsList = false;
-    bInUse = false;
-    // release mutex before aIt destructor call
-    aGuard.clear();
 }
 
 
diff --git a/cppuhelper/source/interfacecontainer.cxx b/cppuhelper/source/interfacecontainer.cxx
index 38cca295755b..035f93848bf2 100644
--- a/cppuhelper/source/interfacecontainer.cxx
+++ b/cppuhelper/source/interfacecontainer.cxx
@@ -281,18 +281,17 @@ void OInterfaceContainerHelper::disposeAndClear( const EventObject & rEvt )
 
 void OInterfaceContainerHelper::clear()
 {
-    ClearableMutexGuard aGuard( rMutex );
-    OInterfaceIteratorHelper aIt( *this );
+    MutexGuard aGuard( rMutex );
     // Release container, in case new entries come while disposing
     OSL_ENSURE( !bIsList || bInUse, "OInterfaceContainerHelper not in use" );
-    if( !bIsList && aData.pAsInterface )
+    if (bInUse)
+        copyAndResetInUse();
+    if (bIsList)
+        delete aData.pAsVector;
+    else if (aData.pAsInterface)
         aData.pAsInterface->release();
-    // set the member to null, use the iterator to delete the values
     aData.pAsInterface = nullptr;
     bIsList = false;
-    bInUse = false;
-    // release mutex before aIt destructor call
-    aGuard.clear();
 }
 
 // specialized class for type


More information about the Libreoffice-commits mailing list