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

No longer fail to start NVDA from sources on Windows 7 when setting DPI awareness #14161

Merged

Conversation

lukaszgo1
Copy link
Contributor

Link to issue number:

None - fix-up of #13254

Summary of the issue:

After #13254 got merged NVDA failed to start from sources on Windows 7 with the following exception:

CRITICAL - __main__ (16:59:34.992) - MainThread (6908):
core failure
Traceback (most recent call last):
  File "nvda.pyw", line 393, in <module>
    core.main()
  File "core.py", line 436, in main
    setDPIAwareness()
  File "winAPI\dpiAwareness.py", line 67, in setDPIAwareness
    hResult = ctypes.windll.shcore.SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE)
  File "C:\Python37\lib\ctypes\__init__.py", line 434, in __getattr__
    dll = self._dlltype(name)
  File "C:\Python37\lib\ctypes\__init__.py", line 364, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module cannot be found

While we handle different versions of Windows by catching AttributeError if the given function for setting DPI awareness is not present on Windows 7 shcore is missing and ctypes raises a different error for missing libraries.

Description of user facing changes

NVDA can once again start from sources when running on Windows 7.

Description of development approach

In addition to catching AttributeError we also catch WindowsError and inspect its error code. If it is caused by the missing library appropriate info is logged and the function continues to use legacy method of setting DPI awareness. Note that AttributeError has to be handled as well to allow NVDA to start on Windows 8/Server 2012.

Testing strategy:

Made sure that NVDA can start from sources on Windows 7, Server 2012 and Windows 10.

Known issues with pull request:

The raised exception is different in Python 3.7 and more recent versions of Python. This information is included as a code comment, so that this is not forgotten when updating the version of Python we're using.

Change log entries:

None needed -unreleased regression which affects only source copies.

Code Review Checklist:

  • Pull Request description:
    • description is up to date
    • change log entries
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • API is compatible with existing add-ons.
  • Documentation:
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • Security precautions taken.

@lukaszgo1 lukaszgo1 requested a review from a team as a code owner September 18, 2022 15:12
@seanbudd seanbudd merged commit 2de9755 into nvaccess:master Sep 19, 2022
@nvaccessAuto nvaccessAuto added this to the 2022.4 milestone Sep 19, 2022
@lukaszgo1 lukaszgo1 deleted the win7DPIAwarenessFromSourceNoCrash branch September 19, 2022 05:50
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.

None yet

3 participants