From 37746d2f710957923427b25c028910d12860e008 Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Wed, 20 Apr 2022 13:59:16 +0200 Subject: Android: fix A11Y object description This patch amends a374d59abc415eee1866322176b7762158f48abd. That commit introduced refactoring of A11Y object description announcements that also took a value into account. However for the elements without values (like QPushButton), an unused space is added at the end of the description. This patch fixes the issue by explicitly checking that the value interface exists and that the value string is not empty. Fixes: QTBUG-102744 Pick-to: 6.3 6.2 5.15 Change-Id: Ic1ba50859fb91c871c242189967dcce35723a0b2 Reviewed-by: Andreas Buhr --- src/plugins/platforms/android/androidjniaccessibility.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/plugins/platforms/android/androidjniaccessibility.cpp') diff --git a/src/plugins/platforms/android/androidjniaccessibility.cpp b/src/plugins/platforms/android/androidjniaccessibility.cpp index e00db7b8ef..db40aaa54c 100644 --- a/src/plugins/platforms/android/androidjniaccessibility.cpp +++ b/src/plugins/platforms/android/androidjniaccessibility.cpp @@ -433,10 +433,13 @@ if (!clazz) { \ desc = iface->text(QAccessible::Value); hasValue = !desc.isEmpty(); } - if (!hasValue) { - if (!desc.isEmpty()) - desc.append(QChar(QChar::Space)); - desc.append(textFromValue(iface)); + if (!hasValue && iface->valueInterface()) { + const QString valueStr = textFromValue(iface); + if (!valueStr.isEmpty()) { + if (!desc.isEmpty()) + desc.append(QChar(QChar::Space)); + desc.append(valueStr); + } } } return desc; -- cgit v1.2.3