Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error in chooseNVDAObjectOverlayClasses #102

Merged
merged 1 commit into from
Jun 24, 2024

Conversation

CyrilleB79
Copy link
Contributor

Issue

In A8M 4.1.1 with NVDA 2024.2, there are two errors in chooseNVDAObjectOverlayClasses:

Error 1: in 6pad++ editor's edit field

ERROR - NVDAObjects.__call__ (11:34:02.700) - MainThread (1600):
Exception in chooseNVDAObjectOverlayClasses for GlobalPlugin ('globalPlugins.Access8Math')
Traceback (most recent call last):
  File "NVDAObjects\__init__.pyc", line 118, in __call__
  File "C:\Users\Cyrille\AppData\Roaming\nvda\addons\Access8Math\globalPlugins\Access8Math\__init__.py", line 260, in chooseNVDAObjectOverlayClasses
    if _("Access8Math Editor") in obj.parent.parent.name or obj.appModule.appName.startswith("notepad"):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not iterable

This error occurs because obj.parent.parent.name is None

Error 2: When locking the computer pressing windows+L

ERROR - NVDAObjects.__call__ (11:30:04.212) - MainThread (1600):
Exception in chooseNVDAObjectOverlayClasses for GlobalPlugin ('globalPlugins.Access8Math')
Traceback (most recent call last):
  File "NVDAObjects\__init__.pyc", line 118, in __call__
  File "C:\Users\Cyrille\AppData\Roaming\nvda\addons\Access8Math\globalPlugins\Access8Math\__init__.py", line 256, in chooseNVDAObjectOverlayClasses
    if obj.windowClassName == "wxWindowNR" and obj.role == ROLE_WINDOW and obj.name == _("Access8Math interaction window"):
       ^^^^^^^^^^^^^^^^^^^
AttributeError: '_SecureDesktopNVDAObject' object has no attribute 'windowClassName'

This error occurs because not all NVDAObjects have an attribute windowClassName; only the ones constructed from a real window (NVDAObjects.window.Window) which are the vast majority have.

Please remember this; I think I had already fixed such an issue in the past.

Fixes

Error 1

Also filter on TypeError in the except clause

Error 2:

Instead of obj.windowClassName, use getattr(obj, 'windowClassName', None) instead. This allows to return None when the attribute does not exist rather than raising AttributeError exception.

@tsengwoody tsengwoody merged commit 8a36293 into tsengwoody:master Jun 24, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants