comphelper/source/misc/accessiblewrapper.cxx | 25 +++++++++++++++++++------ include/comphelper/accessiblewrapper.hxx | 5 ++++- 2 files changed, 23 insertions(+), 7 deletions(-)
New commits: commit d9e31f3c82082226dbc5afa697d0f0ac7e4214a2 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Sep 6 15:26:09 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Sep 6 20:24:16 2023 +0200 tdf#156683 a11y: Handle both disposing variants in context wrapper commit db0044242a897e447988169630ff74e4c8bfecf9 Author: Michael Weghorn <m.wegh...@posteo.de> Date: Wed Sep 6 09:12:23 2023 +0200 tdf#156683 a11y: Forward when wrapped a11y context is disposing switched from overriding `disposing()` to overriding `disposing(const css::lang::EventObject&)` in `OAccessibleContextWrapperHelper` in order to make sure that the corresponding entry in the `AccessibleEventNotifier` client map is removed and event listeners for the wrapper get notified (via `AccessibleEventNotifier::revokeClientNotifyDisposing`) when the wrapped object is disposing. As Noel points out in [1], the `disposing()` case should probably still be overriden/handled and make sure that the wrapped object etc. get disposed, so disposing one object via the other works both ways. (If the wrapped object is disposed, so is the wrapper. If the wrapper gets disposed, so is the wrapped object.) Therefore, add back `OAccessibleContextWrapper::disposing()` and extract the logic to a separate helper method that is called from both `disposing` variants. [1] https://gerrit.libreoffice.org/c/core/+/156592/comments/bb7c24bc_94033649 Change-Id: If15fd1839b222ad94fcbc569842dc43b517d3574 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156620 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/comphelper/source/misc/accessiblewrapper.cxx b/comphelper/source/misc/accessiblewrapper.cxx index bd66b7534d46..3e356f434faa 100644 --- a/comphelper/source/misc/accessiblewrapper.cxx +++ b/comphelper/source/misc/accessiblewrapper.cxx @@ -585,12 +585,8 @@ namespace comphelper } - void SAL_CALL OAccessibleContextWrapper::disposing(const css::lang::EventObject& rEvent) + void OAccessibleContextWrapper::implDisposing(const css::lang::EventObject* pEvent) { - assert(rEvent.Source == Reference<XInterface>(m_xInnerContext, UNO_QUERY) - && "OAccessibleContextWrapper::disposing called with event source that's not the " - "wrapped a11y context"); - AccessibleEventNotifier::TClientId nClientId( 0 ); // --- <mutex lock> ----------------------------------------- @@ -607,12 +603,29 @@ namespace comphelper // --- </mutex lock> ----------------------------------------- // let the base class do - OAccessibleContextWrapperHelper::disposing(rEvent); + if (pEvent) + OAccessibleContextWrapperHelper::disposing(*pEvent); + else + OAccessibleContextWrapperHelper::dispose(); // notify the disposal if ( nClientId ) AccessibleEventNotifier::revokeClientNotifyDisposing( nClientId, *this ); } + + void SAL_CALL OAccessibleContextWrapper::disposing() + { + implDisposing(nullptr); + } + + void SAL_CALL OAccessibleContextWrapper::disposing(const css::lang::EventObject& rEvent) + { + assert(rEvent.Source == Reference<XInterface>(m_xInnerContext, UNO_QUERY) + && "OAccessibleContextWrapper::disposing called with event source that's not the " + "wrapped a11y context"); + + implDisposing(&rEvent); + } } // namespace accessibility diff --git a/include/comphelper/accessiblewrapper.hxx b/include/comphelper/accessiblewrapper.hxx index c2ababe40e1a..089c143b971f 100644 --- a/include/comphelper/accessiblewrapper.hxx +++ b/include/comphelper/accessiblewrapper.hxx @@ -297,8 +297,11 @@ namespace comphelper // OAccessibleContextWrapper virtual void notifyTranslatedEvent( const css::accessibility::AccessibleEventObject& _rEvent ) override; + // helper method for both 'disposing' methods + void implDisposing(const css::lang::EventObject* pEvent); + // OComponentHelper - using cppu::WeakComponentImplHelperBase::disposing; + void SAL_CALL disposing() override; // XAccessibleEventListener virtual void SAL_CALL disposing(const css::lang::EventObject& rEvent) override;