From 2ef2eed768a1a484c41114b88baf1187eb3a8deb Mon Sep 17 00:00:00 2001 From: Michael Curran Date: Fri, 26 Mar 2021 10:24:17 +1000 Subject: [PATCH 1/3] UIA NVDAObject's states property: catch COMError when fetching annotationTypes UIA property, as an exception may be raised on Windows 7. --- source/NVDAObjects/UIA/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/NVDAObjects/UIA/__init__.py b/source/NVDAObjects/UIA/__init__.py index fe72d201230..083fa0b87bf 100644 --- a/source/NVDAObjects/UIA/__init__.py +++ b/source/NVDAObjects/UIA/__init__.py @@ -1462,7 +1462,11 @@ def _get_states(self): states.add(controlTypes.STATE_CHECKABLE) if s==UIAHandler.ToggleState_On: states.add(controlTypes.STATE_CHECKED) - annotationTypes = self._getUIACacheablePropertyValue(UIAHandler.UIA_AnnotationTypesPropertyId) + # annotationTypes cannot be fetched on older Operating Systems such as Windows 7. + try: + annotationTypes = self._getUIACacheablePropertyValue(UIAHandler.UIA_AnnotationTypesPropertyId) + except COMError: + annotationTypes = None if annotationTypes: if UIAHandler.AnnotationType_Comment in annotationTypes: states.add(controlTypes.STATE_HASCOMMENT) From e6d49b1be089f0bf9c174c5fbd4389e02bc6c016 Mon Sep 17 00:00:00 2001 From: Michael Curran Date: Fri, 26 Mar 2021 10:50:53 +1000 Subject: [PATCH 2/3] UIA NVDAObject's UIASelectionPattern2 property: catch COMError, such as on Windows 7. --- source/NVDAObjects/UIA/__init__.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/source/NVDAObjects/UIA/__init__.py b/source/NVDAObjects/UIA/__init__.py index 083fa0b87bf..4b59783fdd3 100644 --- a/source/NVDAObjects/UIA/__init__.py +++ b/source/NVDAObjects/UIA/__init__.py @@ -1193,10 +1193,14 @@ def _get_UIASelectionPattern(self): return self.UIASelectionPattern def _get_UIASelectionPattern2(self): - self.UIASelectionPattern2 = self._getUIAPattern( - UIAHandler.UIA_SelectionPattern2Id, - UIAHandler.IUIAutomationSelectionPattern2 - ) + # SelectionPattern2 is not available on older Operating Systems such as Windows 7 + try: + self.UIASelectionPattern2 = self._getUIAPattern( + UIAHandler.UIA_SelectionPattern2Id, + UIAHandler.IUIAutomationSelectionPattern2 + ) + except COMError: + self.UIASelectionPattern2 = None return self.UIASelectionPattern2 def getSelectedItemsCount(self, maxItems=None): From ea82d47a00aa68c4146b366ba014d1c3527fab77 Mon Sep 17 00:00:00 2001 From: Michael Curran Date: Fri, 26 Mar 2021 14:34:36 +1000 Subject: [PATCH 3/3] Address review actions --- source/NVDAObjects/UIA/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/NVDAObjects/UIA/__init__.py b/source/NVDAObjects/UIA/__init__.py index 4b59783fdd3..660bd37d596 100644 --- a/source/NVDAObjects/UIA/__init__.py +++ b/source/NVDAObjects/UIA/__init__.py @@ -1193,13 +1193,13 @@ def _get_UIASelectionPattern(self): return self.UIASelectionPattern def _get_UIASelectionPattern2(self): - # SelectionPattern2 is not available on older Operating Systems such as Windows 7 try: self.UIASelectionPattern2 = self._getUIAPattern( UIAHandler.UIA_SelectionPattern2Id, UIAHandler.IUIAutomationSelectionPattern2 ) except COMError: + # SelectionPattern2 is not available on older Operating Systems such as Windows 7 self.UIASelectionPattern2 = None return self.UIASelectionPattern2 @@ -1466,10 +1466,10 @@ def _get_states(self): states.add(controlTypes.STATE_CHECKABLE) if s==UIAHandler.ToggleState_On: states.add(controlTypes.STATE_CHECKED) - # annotationTypes cannot be fetched on older Operating Systems such as Windows 7. try: annotationTypes = self._getUIACacheablePropertyValue(UIAHandler.UIA_AnnotationTypesPropertyId) except COMError: + # annotationTypes cannot be fetched on older Operating Systems such as Windows 7. annotationTypes = None if annotationTypes: if UIAHandler.AnnotationType_Comment in annotationTypes: