Windows QPA: Fix crashes when using screen reader with Q(Plain)TextEdit
Make sure the search start with valid values. Task-number: QTBUG-89354 Change-Id: I5b5100db89c62f23748b5c88e9188cfe3811e6e8 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> (cherry picked from commit 7b7dda654acda884b8ebf6e7f2bfed315a566801) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
4f7790e0b1
commit
0b758a57c8
@ -143,7 +143,9 @@ HRESULT QWindowsUiaTextRangeProvider::ExpandToEnclosingUnit(TextUnit unit)
|
|||||||
m_endOffset = m_startOffset + 1;
|
m_endOffset = m_startOffset + 1;
|
||||||
} else {
|
} else {
|
||||||
QString text = textInterface->text(0, len);
|
QString text = textInterface->text(0, len);
|
||||||
for (int t = m_startOffset; t >= 0; --t) {
|
const int start = m_startOffset >= 0 && m_startOffset < len
|
||||||
|
? m_startOffset : len - 1;
|
||||||
|
for (int t = start; t >= 0; --t) {
|
||||||
if (!isTextUnitSeparator(unit, text[t]) && ((t == 0) || isTextUnitSeparator(unit, text[t - 1]))) {
|
if (!isTextUnitSeparator(unit, text[t]) && ((t == 0) || isTextUnitSeparator(unit, text[t - 1]))) {
|
||||||
m_startOffset = t;
|
m_startOffset = t;
|
||||||
break;
|
break;
|
||||||
@ -443,7 +445,9 @@ HRESULT QWindowsUiaTextRangeProvider::MoveEndpointByUnit(TextPatternRangeEndpoin
|
|||||||
}
|
}
|
||||||
m_endOffset = qBound(m_startOffset, m_endOffset, len);
|
m_endOffset = qBound(m_startOffset, m_endOffset, len);
|
||||||
} else {
|
} else {
|
||||||
for (int t = m_startOffset - 1; (t >= 0) && (moved > count); --t) {
|
const int start = m_startOffset >= 0 && m_startOffset <= len
|
||||||
|
? m_startOffset : len;
|
||||||
|
for (int t = start - 1; (t >= 0) && (moved > count); --t) {
|
||||||
if (!isTextUnitSeparator(unit, text[t]) && ((t == 0) || isTextUnitSeparator(unit, text[t - 1]))) {
|
if (!isTextUnitSeparator(unit, text[t]) && ((t == 0) || isTextUnitSeparator(unit, text[t - 1]))) {
|
||||||
m_startOffset = t;
|
m_startOffset = t;
|
||||||
--moved;
|
--moved;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user