From bcd0a3220348778c0d72faac202efb97f4d6dd07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20de=20la=20Rocha?= Date: Fri, 25 Mar 2022 19:54:01 -0300 Subject: [PATCH] Windows QPA: Avoid slowdown with UI Automation name change notification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A previous fix for QTBUG-70621, which allowed changes in the state of a Quick combo box control to be detected by accessibility clients has reportedly caused significant slowdowns under some difficult to reproduce circumstances, probably associated with a large number of accessible objects. This patch restricts the name change notification to combo boxes, which seem to be the only kind of control requiring them for accessibility, instead of sending it for all control types. Fixes: QTBUG-97103 Pick-to: 6.2 6.3 5.15 Change-Id: I18c0067478df5a80f7365195d3559b3f04faa815 Reviewed-by: Jan Arve Sæther --- .../uiautomation/qwindowsuiamainprovider.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp index 7082fe9bd30..2913f0ed680 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp @@ -214,12 +214,16 @@ void QWindowsUiaMainProvider::notifyValueChange(QAccessibleValueChangeEvent *eve void QWindowsUiaMainProvider::notifyNameChange(QAccessibleEvent *event) { if (QAccessibleInterface *accessible = event->accessibleInterface()) { - if (QWindowsUiaMainProvider *provider = providerForAccessible(accessible)) { - VARIANT oldVal, newVal; - clearVariant(&oldVal); - setVariantString(accessible->text(QAccessible::Name), &newVal); - QWindowsUiaWrapper::instance()->raiseAutomationPropertyChangedEvent(provider, UIA_NamePropertyId, oldVal, newVal); - ::SysFreeString(newVal.bstrVal); + // Restrict notification to combo boxes, which need it for accessibility, + // in order to avoid slowdowns with unnecessary notifications. + if (accessible->role() == QAccessible::ComboBox) { + if (QWindowsUiaMainProvider *provider = providerForAccessible(accessible)) { + VARIANT oldVal, newVal; + clearVariant(&oldVal); + setVariantString(accessible->text(QAccessible::Name), &newVal); + QWindowsUiaWrapper::instance()->raiseAutomationPropertyChangedEvent(provider, UIA_NamePropertyId, oldVal, newVal); + ::SysFreeString(newVal.bstrVal); + } } } }