From e4e208fa2b0930be5a7cbbe2fab2ff2fe2c4a1ff Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Tue, 15 Nov 2016 21:56:32 -0500 Subject: [PATCH] tdf#71409: properly remove itself from the context it listens. When the context itself is being disposed. While this solves the issue of addAccessibleEventListener() being called twice despite removeAccessibleEventListener() being called only once, it won't solve the problem of leaky atk focus events. Change-Id: I984107ed2d30e6dba8067d11f400ff64d665d157 --- vcl/unx/gtk/a11y/atklistener.cxx | 9 +++++++++ vcl/unx/gtk/a11y/atkwrapper.cxx | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/vcl/unx/gtk/a11y/atklistener.cxx b/vcl/unx/gtk/a11y/atklistener.cxx index 9dfa66862b0b..5cc6083fc288 100644 --- a/vcl/unx/gtk/a11y/atklistener.cxx +++ b/vcl/unx/gtk/a11y/atklistener.cxx @@ -196,6 +196,15 @@ void AtkListener::handleChildRemoved( // for now. if( nIndex >= 0 ) { + uno::Reference xBroadcaster( + rxChild->getAccessibleContext(), uno::UNO_QUERY); + + if (xBroadcaster.is()) + { + uno::Reference xListener(this); + xBroadcaster->removeAccessibleEventListener(xListener); + } + updateChildList(rxParent); AtkObject * pChild = atk_object_wrapper_ref( rxChild, false ); diff --git a/vcl/unx/gtk/a11y/atkwrapper.cxx b/vcl/unx/gtk/a11y/atkwrapper.cxx index 0d4618ae6c23..52f92186c846 100644 --- a/vcl/unx/gtk/a11y/atkwrapper.cxx +++ b/vcl/unx/gtk/a11y/atkwrapper.cxx @@ -846,7 +846,10 @@ atk_object_wrapper_new( const css::uno::Reference< css::accessibility::XAccessib { uno::Reference< accessibility::XAccessibleEventBroadcaster > xBroadcaster(xContext, uno::UNO_QUERY); if( xBroadcaster.is() ) - xBroadcaster->addAccessibleEventListener( static_cast< accessibility::XAccessibleEventListener * > ( new AtkListener(pWrap) ) ); + { + uno::Reference xListener(new AtkListener(pWrap)); + xBroadcaster->addAccessibleEventListener(xListener); + } else OSL_ASSERT( false ); }