diff options
| author | Even Oscar Andersen <even.oscar.andersen@qt.io> | 2025-10-17 08:56:51 +0200 |
|---|---|---|
| committer | Even Oscar Andersen <even.oscar.andersen@qt.io> | 2025-12-05 06:42:13 +0100 |
| commit | bd66cc612c5616acede64c7dd8836ef46c73f89d (patch) | |
| tree | e72c6d8b13db1331d70b4405c0d77d2bba282a76 /src | |
| parent | 8b4571a3b752d7b02bb44d83c0326fd3d9677a1e (diff) | |
a11y - Send ObjectDestroyed for interfaces without objects
Interfaces without an object calls deleteInterface directly,
issue ObjectDestroyed events also in this situation.
Task-number: QTBUG-141125
Change-Id: I0dc7ff5e45a5fe61af01957eb4c8088cc2e64e17
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src')
| -rw-r--r-- | src/gui/accessible/qaccessiblecache.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/gui/accessible/qaccessiblecache.cpp b/src/gui/accessible/qaccessiblecache.cpp index a8255e04c02..311b53aeaa3 100644 --- a/src/gui/accessible/qaccessiblecache.cpp +++ b/src/gui/accessible/qaccessiblecache.cpp @@ -4,6 +4,7 @@ #include "qaccessiblecache_p.h" #include <QtCore/qdebug.h> #include <QtCore/qloggingcategory.h> +#include <private/qguiapplication_p.h> #if QT_CONFIG(accessibility) @@ -176,10 +177,28 @@ void QAccessibleCache::sendObjectDestroyedEvent(QObject *obj) void QAccessibleCache::deleteInterface(QAccessible::Id id, QObject *obj) { - QAccessibleInterface *iface = idToInterface.take(id); + const auto it = idToInterface.find(id); + if (it == idToInterface.end()) // the interface may be deleted already + return; + + QAccessibleInterface *iface = *it; qCDebug(lcAccessibilityCache) << "delete - id:" << id << " iface:" << iface; - if (!iface) // the interface may be deleted already + if (!iface) { + idToInterface.erase(it); return; + } + + // QObjects sends this from their destructor, but + // the object less interfaces calls deleteInterface + // directly + if (!obj && !iface->object()) { + if (QGuiApplicationPrivate::is_app_running && !QGuiApplicationPrivate::is_app_closing && QAccessible::isActive()) { + QAccessibleObjectDestroyedEvent event(id); + QAccessible::updateAccessibility(&event); + } + } + + idToInterface.erase(it); interfaceToId.take(iface); if (!obj) obj = iface->object(); |
