diff options
-rw-r--r-- | comphelper/source/container/interfacecontainer2.cxx | 13 | ||||
-rw-r--r-- | cppuhelper/source/interfacecontainer.cxx | 13 |
2 files changed, 12 insertions, 14 deletions
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 |