From 2b8cf734e3f70d96419119e2a21293c617b2e167 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 15 Jan 2020 10:03:37 +0200 Subject: improve "convert OSL_ASSERT to assert" this fixes commit 3a0c4574449fc2313306c4e0e39bb7416cc20657, by converting the assert in removeInterface() to SAL_WARN_IF, and similarly for the related addInterface() method Comment from sberg on the original commit: This leaves OInterfaceContainerHelper::add-/removeInterface in somewhat inconsistent state (as addInterface OSL_ASSERTs non-null but then also explicitly checks for null, i.e., effectively supports null). css.lang.XComponent::add-/removeEventListener do not explicitly specify whether or not their arg may be null. I /think/ we traditionally supported null; asserting non-null thus might cause issues for 3rd-party code. Change-Id: I1e28cc03aa7dfe662125c573d60b447309009448 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/86827 Tested-by: Jenkins Reviewed-by: Noel Grandin --- cppuhelper/source/interfacecontainer.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'cppuhelper') diff --git a/cppuhelper/source/interfacecontainer.cxx b/cppuhelper/source/interfacecontainer.cxx index eac0683329bb..a496b93fc372 100644 --- a/cppuhelper/source/interfacecontainer.cxx +++ b/cppuhelper/source/interfacecontainer.cxx @@ -23,6 +23,7 @@ #include #include +#include #include @@ -190,7 +191,7 @@ void OInterfaceContainerHelper::copyAndResetInUse() sal_Int32 OInterfaceContainerHelper::addInterface( const Reference & rListener ) { - OSL_ASSERT( rListener.is() ); + SAL_WARN_IF( !rListener.is(), "cppuhelper", "rListener is empty" ); MutexGuard aGuard( rMutex ); if( bInUse ) copyAndResetInUse(); @@ -221,7 +222,7 @@ sal_Int32 OInterfaceContainerHelper::addInterface( const Reference & sal_Int32 OInterfaceContainerHelper::removeInterface( const Reference & rListener ) { - assert( rListener.is() ); + SAL_WARN_IF( !rListener.is(), "cppuhelper", "rListener is empty" ); MutexGuard aGuard( rMutex ); if( bInUse ) copyAndResetInUse(); -- cgit