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@libreoffice.org>
Reviewed-by: Kohei Yoshida <libreoffice@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