diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2022-08-16 12:35:56 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2022-08-16 22:28:16 +0200 |
commit | a65719ec67523cdfc294aeeda527b51ba4d2e17c (patch) | |
tree | 6be15161ae543ea726dc223297c7d236eb2c4dcd | |
parent | 48baddac8f175e628a854f78304a19238e25d529 (diff) |
qt a11y: Clear XAccessible reference when disposing
The `XEventListener::disposing` doc
(in `./udkapi/com/sun/star/lang/XEventListener.idl`) says:
> /** gets called when the broadcaster is about to be disposed.
>
> <p>All listeners and all other objects, which reference the
> broadcaster should release the reference to the source.
> No method should be invoked anymore on this object (
> including XComponent::removeEventListener() ).
> </p>
>
> <p>This method is called for every listener registration
> of derived listener interfaced, not only for registrations
> at XComponent. </p>
> */
Therefore, clear the `XAccessible` reference held in
the associated `QtAccessibleWidget`
in `QtAccessibleEventListener::disposing`.
This also implies that `QtAccessibleWidget::isValid()`
(overriding the `QAccessibleInterface` method)
will return `false` from that point on.
Change-Id: I077dffe6ca3e887707d1f578e947ccf3c2c2a492
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138364
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
-rw-r--r-- | vcl/inc/qt5/QtAccessibleWidget.hxx | 4 | ||||
-rw-r--r-- | vcl/qt5/QtAccessibleEventListener.cxx | 6 | ||||
-rw-r--r-- | vcl/qt5/QtAccessibleWidget.cxx | 2 |
3 files changed, 11 insertions, 1 deletions
diff --git a/vcl/inc/qt5/QtAccessibleWidget.hxx b/vcl/inc/qt5/QtAccessibleWidget.hxx index fdd97b0b407d..0ca17b394123 100644 --- a/vcl/inc/qt5/QtAccessibleWidget.hxx +++ b/vcl/inc/qt5/QtAccessibleWidget.hxx @@ -50,6 +50,10 @@ class QtAccessibleWidget final : public QObject, public: QtAccessibleWidget(const css::uno::Reference<css::accessibility::XAccessible> xAccessible, QObject* pObject); + + void invalidate(); + + // QAccessibleInterface QWindow* window() const override; int childCount() const override; int indexOfChild(const QAccessibleInterface* child) const override; diff --git a/vcl/qt5/QtAccessibleEventListener.cxx b/vcl/qt5/QtAccessibleEventListener.cxx index ee562a4eca38..53256181ea4e 100644 --- a/vcl/qt5/QtAccessibleEventListener.cxx +++ b/vcl/qt5/QtAccessibleEventListener.cxx @@ -353,6 +353,10 @@ void QtAccessibleEventListener::notifyEvent(const css::accessibility::Accessible } } -void QtAccessibleEventListener::disposing(const EventObject& /* Source */) {} +void QtAccessibleEventListener::disposing(const EventObject& /* Source */) +{ + assert(m_pAccessibleWidget); + m_pAccessibleWidget->invalidate(); +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/qt5/QtAccessibleWidget.cxx b/vcl/qt5/QtAccessibleWidget.cxx index d6370877f449..83733e04c285 100644 --- a/vcl/qt5/QtAccessibleWidget.cxx +++ b/vcl/qt5/QtAccessibleWidget.cxx @@ -73,6 +73,8 @@ QtAccessibleWidget::QtAccessibleWidget(const Reference<XAccessible> xAccessible, } } +void QtAccessibleWidget::invalidate() { m_xAccessible.clear(); } + Reference<XAccessibleContext> QtAccessibleWidget::getAccessibleContextImpl() const { Reference<XAccessibleContext> xAc; |