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

Kohei Yoshida kohei.yoshida at collabora.com
Tue Nov 22 13:18:23 UTC 2016


 vcl/unx/gtk/a11y/atklistener.cxx |   20 ++++++++++++++++++++
 vcl/unx/gtk/a11y/atklistener.hxx |    2 ++
 2 files changed, 22 insertions(+)

New commits:
commit 87e040fd0f04307534920d0765af6d5878794a98
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Nov 21 22:56:46 2016 -0500

    tdf#71409: Stop listening to objects going out-of-focus.
    
    This helps eliminate the number of AtkListener objects growing
    over time.
    
    Change-Id: I5cfeac8beae8e950382116544da99ad9c1c1a254
    Reviewed-on: https://gerrit.libreoffice.org/31062
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Kohei Yoshida <libreoffice at kohei.us>

diff --git a/vcl/unx/gtk/a11y/atklistener.cxx b/vcl/unx/gtk/a11y/atklistener.cxx
index 5cc6083..39930b2 100644
--- a/vcl/unx/gtk/a11y/atklistener.cxx
+++ b/vcl/unx/gtk/a11y/atklistener.cxx
@@ -121,6 +121,9 @@ void AtkListener::updateChildList(
     css::uno::Reference<css::accessibility::XAccessibleContext> const &
         pContext)
 {
+    if (!pContext.is())
+        return;
+
      m_aChildList.clear();
 
      uno::Reference< accessibility::XAccessibleStateSet > xStateSet = pContext->getAccessibleStateSet();
@@ -255,6 +258,19 @@ void AtkListener::handleInvalidateChildren(
     }
 }
 
+void AtkListener::stopListening()
+{
+    uno::Reference<accessibility::XAccessibleEventBroadcaster> xBroadcaster(
+        mpWrapper->mpContext.get(), uno::UNO_QUERY);
+
+    if (xBroadcaster.is())
+    {
+        uno::Reference<accessibility::XAccessibleEventListener> xListener(this);
+        if (xListener.is())
+            xBroadcaster->removeAccessibleEventListener(xListener);
+    }
+}
+
 /*****************************************************************************/
 
 static uno::Reference< accessibility::XAccessibleContext >
@@ -346,6 +362,10 @@ void AtkListener::notifyEvent( const accessibility::AccessibleEventObject& aEven
             gboolean bState = eNewState != ATK_STATE_INVALID;
             AtkStateType eRealState = bState ? eNewState : eOldState;
 
+            if (eOldState == ATK_STATE_FOCUSED)
+                // Stop listening to object going out-of-focus.
+                stopListening();
+
             atk_object_notify_state_change( atk_obj, eRealState, bState );
             break;
         }
diff --git a/vcl/unx/gtk/a11y/atklistener.hxx b/vcl/unx/gtk/a11y/atklistener.hxx
index 39dbe5d..fccf031 100644
--- a/vcl/unx/gtk/a11y/atklistener.hxx
+++ b/vcl/unx/gtk/a11y/atklistener.hxx
@@ -66,6 +66,8 @@ private:
     // Process INVALIDATE_ALL_CHILDREN notification
     void handleInvalidateChildren(
         const css::uno::Reference< css::accessibility::XAccessibleContext >& rxParent);
+
+    void stopListening();
 };
 
 #endif // INCLUDED_VCL_UNX_GTK_A11Y_ATKLISTENER_HXX


More information about the Libreoffice-commits mailing list