[Libreoffice-commits] core.git: include/vcl vcl/inc vcl/source vcl/unx

Noel Grandin noel at peralex.com
Sat Sep 19 23:37:21 PDT 2015


 include/vcl/menu.hxx              |    3 --
 vcl/inc/vcleventlisteners.hxx     |   12 --------
 vcl/source/app/vclevent.cxx       |   40 ---------------------------
 vcl/source/window/menu.cxx        |   56 +++++++++++++++++++++++++-------------
 vcl/unx/gtk/window/gtksalmenu.cxx |    9 ++----
 5 files changed, 42 insertions(+), 78 deletions(-)

New commits:
commit e3c3b7fde3c017bd7d25f04fabf9b4528e37fb49
Author: Noel Grandin <noel at peralex.com>
Date:   Fri Sep 18 10:46:37 2015 +0200

    convert Link<> to typed
    
    Change-Id: I86bf78c69251b5cd4d18edf3542e70eb2e8f32e1
    Reviewed-on: https://gerrit.libreoffice.org/18699
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx
index 4566082..160ef8b 100644
--- a/include/vcl/menu.hxx
+++ b/include/vcl/menu.hxx
@@ -404,8 +404,7 @@ public:
 
 namespace vcl { namespace MenuInvalidator {
 
-VCL_DLLPUBLIC void AddMenuInvalidateListener(const Link<>&);
-VCL_DLLPUBLIC void CallMenuInvalidateListeners(VclSimpleEvent* pEvent);
+VCL_DLLPUBLIC void AddMenuInvalidateListener(const Link<LinkParamNone*,void>&);
 VCL_DLLPUBLIC void Invalidated();
 
 }}
diff --git a/vcl/inc/vcleventlisteners.hxx b/vcl/inc/vcleventlisteners.hxx
index 8e3b026..5be40e8 100644
--- a/vcl/inc/vcleventlisteners.hxx
+++ b/vcl/inc/vcleventlisteners.hxx
@@ -41,18 +41,6 @@ private:
     std::vector<Link<>> m_aListeners;
 };
 
-class VCL_DLLPUBLIC VclEventListeners2 : public vcl::DeletionNotifier
-{
-    std::vector<Link<>>   m_aListeners;
-public:
-    VclEventListeners2();
-    ~VclEventListeners2();
-
-    void addListener( const Link<>& );
-    void removeListener( const Link<>& );
-    void callListeners( VclSimpleEvent* );
-};
-
 #endif // INCLUDED_VCL_INC_VCLEVENTLISTENERS_HXX
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/app/vclevent.cxx b/vcl/source/app/vclevent.cxx
index 7cb291d..6cc4523 100644
--- a/vcl/source/app/vclevent.cxx
+++ b/vcl/source/app/vclevent.cxx
@@ -87,46 +87,6 @@ void VclEventListeners::removeListener( const Link<>& rListener )
     m_aListeners.erase( std::remove(m_aListeners.begin(), m_aListeners.end(), rListener ), m_aListeners.end() );
 }
 
-VclEventListeners2::VclEventListeners2()
-{
-}
-
-VclEventListeners2::~VclEventListeners2()
-{
-}
-
-void VclEventListeners2::addListener( const Link<>& rListener )
-{
-    // ensure uniqueness
-    if (std::find(m_aListeners.begin(), m_aListeners.end(), rListener) == m_aListeners.end())
-       m_aListeners.push_back( rListener );
-}
-
-void VclEventListeners2::removeListener( const Link<>& rListener )
-{
-    m_aListeners.erase( std::remove(m_aListeners.begin(), m_aListeners.end(), rListener ), m_aListeners.end() );
-}
-
-void VclEventListeners2::callListeners( VclSimpleEvent* pEvent )
-{
-    vcl::DeletionListener aDel( this );
-
-    // Copy the list, because this can be destroyed when calling a Link...
-    std::vector<Link<>> aCopy( m_aListeners );
-    std::vector<Link<>>::iterator aIter( aCopy.begin() );
-    std::vector<Link<>>::const_iterator aEnd( aCopy.end() );
-
-    while ( aIter != aEnd && ! aDel.isDeleted() )
-    {
-        Link<> &rLink = *aIter;
-        // check this hasn't been removed in some re-enterancy scenario fdo#47368
-        if( std::find(m_aListeners.begin(), m_aListeners.end(), rLink) != m_aListeners.end() )
-            rLink.Call( pEvent );
-        ++aIter;
-    }
-}
-
-
 VclWindowEvent::VclWindowEvent( vcl::Window* pWin, sal_uLong n, void* pDat ) : VclSimpleEvent(n)
 {
     pWindow = pWin; pData = pDat;
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index e5acc2e..23f857a 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -3239,25 +3239,43 @@ ImplMenuDelData::~ImplMenuDelData()
 }
 
 namespace vcl { namespace MenuInvalidator {
-    static VclEventListeners2* pMenuInvalidateListeners = NULL;
-    void AddMenuInvalidateListener(const Link<>& rLink)
-    {
-        if(!pMenuInvalidateListeners)
-            pMenuInvalidateListeners = new VclEventListeners2();
-        pMenuInvalidateListeners->addListener(rLink);
-    }
-    void CallMenuInvalidateListeners(VclSimpleEvent* pEvent)
+
+struct MenuInvalidateListeners : public vcl::DeletionNotifier
+{
+    std::vector<Link<LinkParamNone*,void>>   m_aListeners;
+};
+
+static MenuInvalidateListeners* pMenuInvalidateListeners = NULL;
+
+void AddMenuInvalidateListener(const Link<LinkParamNone*,void>& rLink)
+{
+    if(!pMenuInvalidateListeners)
+        pMenuInvalidateListeners = new MenuInvalidateListeners();
+    // ensure uniqueness
+    auto& rListeners = pMenuInvalidateListeners->m_aListeners;
+    if (std::find(rListeners.begin(), rListeners.end(), rLink) == rListeners.end())
+       rListeners.push_back( rLink );
+}
+
+void Invalidated()
+{
+    if(!pMenuInvalidateListeners)
+        return;
+
+    vcl::DeletionListener aDel( pMenuInvalidateListeners );
+
+    auto& rYieldListeners = pMenuInvalidateListeners->m_aListeners;
+    // Copy the list, because this can be destroyed when calling a Link...
+    std::vector<Link<LinkParamNone*,void>> aCopy( rYieldListeners );
+    for( Link<LinkParamNone*,void>& rLink : aCopy )
     {
-        if(pMenuInvalidateListeners)
-            pMenuInvalidateListeners->callListeners(pEvent);
+        if (aDel.isDeleted()) break;
+        // check this hasn't been removed in some re-enterancy scenario fdo#47368
+        if( std::find(rYieldListeners.begin(), rYieldListeners.end(), rLink) != rYieldListeners.end() )
+            rLink.Call( nullptr );
     }
-    void Invalidated()
-    {
-        if(pMenuInvalidateListeners)
-        {
-            VclSimpleEvent aEvent(0);
-            pMenuInvalidateListeners->callListeners(&aEvent);
-        }
-    };
-} }
+};
+
+} } // namespace vcl::MenuInvalidator
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/gtk/window/gtksalmenu.cxx b/vcl/unx/gtk/window/gtksalmenu.cxx
index ba2c894..bb53b14 100644
--- a/vcl/unx/gtk/window/gtksalmenu.cxx
+++ b/vcl/unx/gtk/window/gtksalmenu.cxx
@@ -392,20 +392,19 @@ static gboolean RefreshMenusUnity(gpointer)
     return FALSE;
 }
 
-static long RefreshMenusUnity(void*, void*)
+static void RefreshMenusUnity(void*, LinkParamNone*)
 {
     if(!bInvalidMenus) {
         g_timeout_add(10, &RefreshMenusUnity, NULL);
         bInvalidMenus = true;
     }
-    return 0;
 }
 
-static Link<>* getRefreshLinkInstance()
+static Link<LinkParamNone*,void>* getRefreshLinkInstance()
 {
-    static Link<>* pLink = NULL;
+    static Link<LinkParamNone*,void>* pLink = NULL;
     if(!pLink) {
-        pLink = new Link<>(NULL, &RefreshMenusUnity);
+        pLink = new Link<LinkParamNone*,void>(NULL, &RefreshMenusUnity);
     }
     return pLink;
 }


More information about the Libreoffice-commits mailing list