QAbstractButton::setChecked() - don't update accessibility if stale

A QPointer is used as a guard for calling setChecked on a stale object.
The guard is not checked on accessibility updates.

This patch wraps the accessibility update in a guard check.

Fixes: QTBUG-112759
Pick-to: 6.5
Change-Id: Ida47c181b7968911c1805dc244b86347e7afe81b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Axel Spoerl 2023-04-12 19:43:30 +02:00
parent 143d00cc2c
commit d953bc76bb

View File

@ -613,12 +613,13 @@ void QAbstractButton::setChecked(bool checked)
if (guard)
d->emitToggled(checked);
#if QT_CONFIG(accessibility)
QAccessible::State s;
s.checked = true;
QAccessibleStateChangeEvent event(this, s);
QAccessible::updateAccessibility(&event);
if (guard) {
QAccessible::State s;
s.checked = true;
QAccessibleStateChangeEvent event(this, s);
QAccessible::updateAccessibility(&event);
}
#endif
}