From 7238948dbba174578c0d88860e66f4f3c7f17315 Mon Sep 17 00:00:00 2001 From: Fushan Wen <qydwhotmail@gmail.com> Date: Sat, 23 Jul 2022 00:48:37 +0800 Subject: [PATCH 059/147] Send string to Atspi DBus interface on name/description changed Orca only accepts string or list type for object:property-change:accessible-name and object:property-change:accessible-description events. This fixes NameChanged and DescriptionChanged not being announced by Orca. This also adds check for accessible interface and will ignore events from invalid interfaces on name/description changed. See also: https://gitlab.gnome.org/GNOME/orca/-/issues/255 Pick-to: 6.4 6.2 Change-Id: Iaaa50678e7223951e0f3af99c5e04aa7458e4d0d Reviewed-by: Michael Weghorn <m.weghorn@posteo.de> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit c9758d76c73c7e4bf6363a7f357ad8c2dfb8b4bc) CCMAIL: kde-accessibility@kde.org --- .../linuxaccessibility/atspiadaptor.cpp | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp index 7ea6680fba..c8c717ba6b 100644 --- a/src/platformsupport/linuxaccessibility/atspiadaptor.cpp +++ b/src/platformsupport/linuxaccessibility/atspiadaptor.cpp @@ -913,8 +913,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event) } case QAccessible::NameChanged: { if (sendObject || sendObject_property_change || sendObject_property_change_accessible_name) { - QString path = pathForInterface(event->accessibleInterface()); - QVariantList args = packDBusSignalArguments(QLatin1String("accessible-name"), 0, 0, variantForPath(path)); + QAccessibleInterface *iface = event->accessibleInterface(); + if (!iface) { + qCDebug(lcAccessibilityAtspi, + "NameChanged event from invalid accessible."); + return; + } + + QString path = pathForInterface(iface); + QVariantList args = packDBusSignalArguments( + QLatin1String("accessible-name"), 0, 0, + QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Name)))); sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT), QLatin1String("PropertyChange"), args); } @@ -922,8 +931,17 @@ void AtSpiAdaptor::notify(QAccessibleEvent *event) } case QAccessible::DescriptionChanged: { if (sendObject || sendObject_property_change || sendObject_property_change_accessible_description) { - QString path = pathForInterface(event->accessibleInterface()); - QVariantList args = packDBusSignalArguments(QLatin1String("accessible-description"), 0, 0, variantForPath(path)); + QAccessibleInterface *iface = event->accessibleInterface(); + if (!iface) { + qCDebug(lcAccessibilityAtspi, + "DescriptionChanged event from invalid accessible."); + return; + } + + QString path = pathForInterface(iface); + QVariantList args = packDBusSignalArguments( + QLatin1String("accessible-description"), 0, 0, + QVariant::fromValue(QDBusVariant(iface->text(QAccessible::Description)))); sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OBJECT), QLatin1String("PropertyChange"), args); } -- 2.40.1