diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-01-25 17:41:43 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-01-26 08:00:59 +0100 |
commit | de60c73db31ec34ffb2e008829083bb7ddcb3061 (patch) | |
tree | 1306878b00c02051c251fa891252a747facd031e /cppuhelper | |
parent | eeb2d19e77d6dc47c68e8ba0920a02cf64a1247b (diff) |
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@collabora.co.uk>
Diffstat (limited to 'cppuhelper')
-rw-r--r-- | cppuhelper/source/interfacecontainer.cxx | 13 |
1 files changed, 6 insertions, 7 deletions
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 |