From db0db36ddc0235c6e202192e7973e2c0109aa45b Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Thu, 18 Aug 2022 11:12:29 +0200 Subject: [PATCH] a11y atspi: Send correct D-Bus reply for GetAttributeValue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only return a string for the attribute value (an empty string if the attribute is not set). The previous implementation was based on the incorrect signature in the XML spec for the AT-SPI Text interface from before the AT-SPI commit that removed the extra out params [1]: commit 8786849ce6e9914383aa766ff9ce7e00f5b2178d Author: Patryk Kaczmarek Date: Mon Sep 28 14:23:15 2015 +0200 Fixed atspi_text_ functions * atspi_text_get_text_attribute_value Fixed dbus signature in _atspi_dbus_call function and add missing argument for string. * atspi_text_get_default_attributes Receiving return value by reference from hash table https://bugzilla.gnome.org/show_bug.cgi?id=755731 [1] https://gitlab.gnome.org/GNOME/at-spi2-core/-/commit/8786849ce6e9914383aa766ff9ce7e00f5b2178d Fixes: QTBUG-105752 Change-Id: I66d3c484ecc4b469684635723242c915e4365e6a Reviewed-by: Tor Arne Vestbø (cherry picked from commit e6599bfa6134cfd3097c9cb8ec45801ae810f3df) Reviewed-by: Qt Cherry-pick Bot --- src/gui/accessible/linux/atspiadaptor.cpp | 14 +++----------- src/gui/accessible/linux/atspiadaptor_p.h | 2 +- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/gui/accessible/linux/atspiadaptor.cpp b/src/gui/accessible/linux/atspiadaptor.cpp index c90732d0a94..9661e517fa4 100644 --- a/src/gui/accessible/linux/atspiadaptor.cpp +++ b/src/gui/accessible/linux/atspiadaptor.cpp @@ -451,9 +451,6 @@ QString AtSpiAdaptor::introspect(const QString &path) const " \n" " \n" " \n" - " \n" - " \n" - " \n" " \n" " \n" " \n" @@ -1761,7 +1758,7 @@ bool AtSpiAdaptor::textInterface(QAccessibleInterface *interface, const QString } else if (function == "GetAttributeValue"_L1) { int offset = message.arguments().at(0).toInt(); QString attributeName = message.arguments().at(1).toString(); - connection.send(message.createReply(getAttributeValue(interface, offset, attributeName))); + connection.send(message.createReply(QVariant(getAttributeValue(interface, offset, attributeName)))); } else if (function == "GetAttributes"_L1) { int offset = message.arguments().at(0).toInt(); connection.send(message.createReply(getAttributes(interface, offset, true))); @@ -2027,9 +2024,8 @@ QVariantList AtSpiAdaptor::getAttributes(QAccessibleInterface *interface, int of return list; } -QVariantList AtSpiAdaptor::getAttributeValue(QAccessibleInterface *interface, int offset, const QString &attributeName) const +QString AtSpiAdaptor::getAttributeValue(QAccessibleInterface *interface, int offset, const QString &attributeName) const { - QString mapped; QString joined; QSpiAttributeSet map; int startOffset; @@ -2044,11 +2040,7 @@ QVariantList AtSpiAdaptor::getAttributeValue(QAccessibleInterface *interface, in if (!attribute.isNull()) map[attribute.name] = attribute.value; } - mapped = map[attributeName]; - const bool defined = !mapped.isEmpty(); - QVariantList list; - list << mapped << startOffset << endOffset << defined; - return list; + return map[attributeName]; } QList AtSpiAdaptor::getCharacterExtents(QAccessibleInterface *interface, int offset, uint coordType) const diff --git a/src/gui/accessible/linux/atspiadaptor_p.h b/src/gui/accessible/linux/atspiadaptor_p.h index 3d785e4c25a..aaabc8c2f18 100644 --- a/src/gui/accessible/linux/atspiadaptor_p.h +++ b/src/gui/accessible/linux/atspiadaptor_p.h @@ -101,7 +101,7 @@ private: // text helper functions QVariantList getAttributes(QAccessibleInterface *, int offset, bool includeDefaults) const; - QVariantList getAttributeValue(QAccessibleInterface *, int offset, const QString &attributeName) const; + QString getAttributeValue(QAccessibleInterface *, int offset, const QString &attributeName) const; QList getCharacterExtents(QAccessibleInterface *, int offset, uint coordType) const; QList getRangeExtents(QAccessibleInterface *, int startOffset, int endOffset, uint coordType) const; QAccessible::TextBoundaryType qAccessibleBoundaryType(int atspiTextBoundaryType) const;