[Libreoffice-commits] core.git: include/svl svl/source

Noel Grandin noel at peralex.com
Fri Jun 6 08:40:06 PDT 2014


 include/svl/lstner.hxx       |    4 ++--
 svl/source/notify/lstner.cxx |   20 +++++++++-----------
 2 files changed, 11 insertions(+), 13 deletions(-)

New commits:
commit a10a621b48a30904b970ce01cc0bf2aa15cea9cb
Author: Noel Grandin <noel at peralex.com>
Date:   Thu May 29 07:54:23 2014 +0200

    simplify SfxListener::EndListening and StartListening
    
    No-one is using the return values, so we can simplify the methods
    
    Change-Id: Icc2dbfb797bcd82afcbf42ed3bdc20b0426ccba1
    Reviewed-on: https://gerrit.libreoffice.org/9542
    Tested-by: Caolán McNamara <caolanm at redhat.com>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/svl/lstner.hxx b/include/svl/lstner.hxx
index 9cc7533..8bf93b9 100644
--- a/include/svl/lstner.hxx
+++ b/include/svl/lstner.hxx
@@ -47,8 +47,8 @@ public:
                         SfxListener( const SfxListener &rCopy );
     virtual             ~SfxListener();
 
-    bool                StartListening( SfxBroadcaster& rBroadcaster, bool bPreventDups = false );
-    bool                EndListening( SfxBroadcaster& rBroadcaster, bool bAllDups = false );
+    void                StartListening( SfxBroadcaster& rBroadcaster, bool bPreventDups = false );
+    void                EndListening( SfxBroadcaster& rBroadcaster, bool bAllDups = false );
     void                EndListeningAll();
     bool                IsListening( SfxBroadcaster& rBroadcaster ) const;
 
diff --git a/svl/source/notify/lstner.cxx b/svl/source/notify/lstner.cxx
index 606b9a6..331f600 100644
--- a/svl/source/notify/lstner.cxx
+++ b/svl/source/notify/lstner.cxx
@@ -65,7 +65,7 @@ void SfxListener::RemoveBroadcaster_Impl( SfxBroadcaster& rBroadcaster )
 
 // registers a specific SfxBroadcaster
 
-bool SfxListener::StartListening( SfxBroadcaster& rBroadcaster, bool bPreventDups )
+void SfxListener::StartListening( SfxBroadcaster& rBroadcaster, bool bPreventDups )
 {
     if ( !bPreventDups || !IsListening( rBroadcaster ) )
     {
@@ -73,27 +73,25 @@ bool SfxListener::StartListening( SfxBroadcaster& rBroadcaster, bool bPreventDup
         aBCs.push_back( &rBroadcaster );
 
         DBG_ASSERT( IsListening(rBroadcaster), "StartListening failed" );
-        return true;
     }
-
-    return false;
 }
 
 
 // unregisters a specific SfxBroadcaster
 
-bool SfxListener::EndListening( SfxBroadcaster& rBroadcaster, bool bAllDups )
+void SfxListener::EndListening( SfxBroadcaster& rBroadcaster, bool bAllDups )
 {
-    if ( !IsListening( rBroadcaster ) )
-        return false;
-
     do
     {
+        SfxBroadcasterArr_Impl::iterator it = std::find( aBCs.begin(), aBCs.end(), &rBroadcaster );
+        if ( it == aBCs.end() )
+        {
+            break;
+        }
         rBroadcaster.RemoveListener(*this);
-        aBCs.erase( std::find( aBCs.begin(), aBCs.end(), &rBroadcaster ) );
+        aBCs.erase( it );
     }
-    while ( bAllDups && IsListening( rBroadcaster ) );
-    return true;
+    while ( bAllDups );
 }
 
 


More information about the Libreoffice-commits mailing list