From ac8467286ac19c30ed16a83bf1bc4c49a7f899f6 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: 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 Change-Id: I18c0067478df5a80f7365195d3559b3f04faa815 Reviewed-by: Jan Arve Sæther (cherry picked from commit bcd0a3220348778c0d72faac202efb97f4d6dd07) Reviewed-by: Qt Cherry-pick Bot --- .../windows/uiautomation/qwindowsuiamainprovider.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp') diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp index 809a7a9a8f..63bf6bc87c 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp @@ -206,12 +206,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); + } } } } -- cgit v1.2.3