Windows QPA: Avoid slowdown with UI Automation name change notification

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 <jan-arve.saether@qt.io>
bb10
André de la Rocha 2022-03-25 19:54:01 -03:00
parent 37b702dc12
commit bcd0a32203
1 changed files with 10 additions and 6 deletions

View File

@ -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);
}
}
}
}