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

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Wed Jan 15 09:35:19 UTC 2020


 cppuhelper/source/interfacecontainer.cxx |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 2b8cf734e3f70d96419119e2a21293c617b2e167
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Jan 15 10:03:37 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Jan 15 10:34:49 2020 +0100

    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 <noel.grandin at collabora.co.uk>

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 <osl/diagnose.h>
 #include <osl/mutex.hxx>
+#include <sal/log.hxx>
 
 #include <memory>
 
@@ -190,7 +191,7 @@ void OInterfaceContainerHelper::copyAndResetInUse()
 
 sal_Int32 OInterfaceContainerHelper::addInterface( const Reference<XInterface> & 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<XInterface> &
 
 sal_Int32 OInterfaceContainerHelper::removeInterface( const Reference<XInterface> & rListener )
 {
-    assert( rListener.is() );
+    SAL_WARN_IF( !rListener.is(), "cppuhelper", "rListener is empty" );
     MutexGuard aGuard( rMutex );
     if( bInUse )
         copyAndResetInUse();


More information about the Libreoffice-commits mailing list