vcl/inc/qt5/QtXAccessible.hxx | 5 +++++ vcl/qt5/QtAccessibleWidget.cxx | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-)
New commits: commit f2371a7d9b306ce217689bd69c920c9f780f1ee3 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Tue Aug 16 14:13:20 2022 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Tue Aug 16 22:29:15 2022 +0200 qt a11y: Clear QtXAccessible's ref to XAccessible once passed on The `QtXAccessible` only needs to hold a reference to the `XAccessible` in order to pass it to the `QtAccessibleWidget` ctor in `QtAccessibleWidget::customFactory` (which gets called via `QAccessible::queryAccessibleInterface`). After that has happened, the `QtAccessibleWidget` holds its own reference in its `m_xAccessible` member and is the only class in the context of the qt a11y bridge that needs access to the `XAccessible`, so drop the reference in the `QtXAccessible` to avoid any references being held even after `QtAccessibleEventListener::disposing` has been called, s.a. Change-Id I077dffe6ca3e887707d1f578e947ccf3c2c2a492 "qt a11y: Clear XAccessible reference when disposing" for some more context. Change-Id: Ief80b2939e4c509fc4bc68e67500dbad66498506 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138365 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/inc/qt5/QtXAccessible.hxx b/vcl/inc/qt5/QtXAccessible.hxx index 4f4285e8065b..ddb7849b641c 100644 --- a/vcl/inc/qt5/QtXAccessible.hxx +++ b/vcl/inc/qt5/QtXAccessible.hxx @@ -28,6 +28,11 @@ class QtXAccessible : public QObject public: QtXAccessible(css::uno::Reference<css::accessibility::XAccessible> xAccessible); + + /** Reference to the XAccessible. + * This is cleared once it has been passed to the QtAccessibleWidget, + * which then keeps an own reference and takes care of all required + * access to the XAccessible for the Qt a11y bridge. */ css::uno::Reference<css::accessibility::XAccessible> m_xAccessible; }; diff --git a/vcl/qt5/QtAccessibleWidget.cxx b/vcl/qt5/QtAccessibleWidget.cxx index 83733e04c285..09d01c6e496f 100644 --- a/vcl/qt5/QtAccessibleWidget.cxx +++ b/vcl/qt5/QtAccessibleWidget.cxx @@ -749,7 +749,12 @@ QAccessibleInterface* QtAccessibleWidget::customFactory(const QString& classname { QtXAccessible* pXAccessible = static_cast<QtXAccessible*>(object); if (pXAccessible && pXAccessible->m_xAccessible.is()) - return new QtAccessibleWidget(pXAccessible->m_xAccessible, object); + { + QtAccessibleWidget* pRet = new QtAccessibleWidget(pXAccessible->m_xAccessible, object); + // clear the reference in the QtXAccessible, no longer needed now that the QtAccessibleWidget holds one + pXAccessible->m_xAccessible.clear(); + return pRet; + } } return nullptr;