Handle error when creating TextInfo from alleged caret object#17212
Merged
SaschaCowley merged 2 commits intoSep 25, 2024
Merged
Conversation
### Link to issue number: Fixes nvaccess#17198 ### Summary of the issue: When using the Microsoft Pinyin Input Method for Chinese and enabling the Pinyin compatibility option to use the previous version, typing in LibreOffice (e.g. Writer or Calc) while an IME popup was showing triggered an error, with this traceback: ERROR - eventHandler.executeEvent (10:45:49.378) - MainThread (7416): error executing event: caret on <NVDAObjects.Dynamic_SymphonyParagraphSymphonyTextEditableTextWithAutoSelectDetectionIAccessible object at 0x0B918DF0> with extra args of {} Traceback (most recent call last): File "eventHandler.py", line 353, in executeEvent _EventExecuter(eventName, obj, kwargs) File "eventHandler.py", line 119, in __init__ self.next() File "eventHandler.py", line 128, in next return func(*args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "compoundDocuments.py", line 548, in event_caret caret = self.makeTextInfo(textInfos.POSITION_CARET) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "documentBase.py", line 76, in makeTextInfo return self.TextInfo(self, position) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "compoundDocuments.py", line 287, in __init__ self._start = self._end = self._startObj.makeTextInfo(position) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "documentBase.py", line 76, in makeTextInfo return self.TextInfo(self, position) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "textInfos\offsets.py", line 505, in __init__ self._startOffset = self._endOffset = self._getCaretOffset() ^^^^^^^^^^^^^^^^^^^^^^ File "textInfos\offsets.py", line 267, in _getCaretOffset raise NotImplementedError NotImplementedError This was caused by the attempt to create a text info for an object from the IME popup that's not actually part of the LibreOffice accessibility tree, and that doesn't provide any means to get the current caret position. This is due to `CompoundDocument._get_caretObject` returning the last queued focus object, which isn't necessarily the object that the caret change event has actually been sent for, and might be an object that doesn't support reporting of a caret positiion altogether. ### Description of user facing changes When using the Microsoft Pinyin Input Method for Chinese and enabling the Pinyin compatibility option to use the previous version, typing in LibreOffice (and potentially other applications) while an IME popup is showing no longer triggers an error. ### Description of development approach Handle the NotImplementedError error that may get thrown in CompoundDocument.event_caret. ### Testing strategy: 1. set up the Microsoft Pinyin Input Method for Chinese and enable the Pinyin compatibility option as described in issue nvaccess#17198 2. start LibreOffice Writer 3. start typing, e.g. just type "e" multiple times 4. Notice the IME popup showing without triggering an error ### Known issues with pull request: None. ### Code Review Checklist: - [x] Documentation: - Change log entry - User Documentation - Developer / Technical Documentation - Context sensitive help for GUI changes - [x] Testing: - Unit tests - System (end to end) tests - Manual testing - [x] UX of all users considered: - Speech - Braille - Low Vision - Different web browsers - Localization in other languages / culture than English - [x] API is compatible with existing add-ons. - [x] Security precautions taken.
Contributor
Author
|
Quoting from #17198 (comment) :
If my understanding is wrong and/or this should better be fixed elsewhere, please let me know. |
* Explicitly mention Writer, there are still more errors with Calc with the old Microsoft Pinyin version, see nvaccess#17198 (comment) * Move entry to the "Bug Fixes" section. This is not a new feature.
SaschaCowley
approved these changes
Sep 25, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to issue number:
Partially fixes #17198
Summary of the issue:
When using the Microsoft Pinyin Input Method for Chinese and enabling the Pinyin compatibility option to use the previous version, typing in LibreOffice (e.g. Writer or Calc) while an IME popup was showing triggered an error, with this traceback:
This was caused by the attempt to create a text info for an object from the IME popup that's not actually part of the LibreOffice accessibility tree, and that doesn't provide any means to get the current caret position.
This is due to
CompoundDocument._get_caretObjectreturning the last queued focus object, which isn't necessarily the object that the caret change event has actually been sent for, and might be an object that doesn't support reporting of a caret positiion altogether.Description of user facing changes
When using the Microsoft Pinyin Input Method for Chinese and enabling the Pinyin compatibility option to use the previous version, typing in LibreOffice Writer (and potentially other applications) while an IME popup is showing no longer triggers an error.
Description of development approach
Handle the NotImplementedError error that may get thrown in CompoundDocument.event_caret.
Testing strategy:
Known issues with pull request:
None, but note that other than Writer, the case of using Calc still shows more issues, s. #17198 (comment) , i.e. this is only a partial fix for the use case described in that ticket.
Code Review Checklist:
@coderabbitai summary