Skip to content

Fix error when displaying math panel#19820

Merged
seanbudd merged 1 commit into
nvaccess:betafrom
CyrilleB79:fixMathPanel
Mar 23, 2026
Merged

Fix error when displaying math panel#19820
seanbudd merged 1 commit into
nvaccess:betafrom
CyrilleB79:fixMathPanel

Conversation

@CyrilleB79

Copy link
Copy Markdown
Contributor

Link to issue number:

Fix-up of #19740

Summary of the issue:

After the merge of #19740, the math panel cannot be displayed and the following error is logged:

ERROR - unhandled exception (15:06:18.687) - MainThread (1844):
Traceback (most recent call last):
  File "gui\settingsDialogs.py", line 6230, in onCategoryChange
    super().onCategoryChange(evt)
    ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "gui\settingsDialogs.py", line 750, in onCategoryChange
    self._doCategoryChange(newIndex)
    ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "gui\settingsDialogs.py", line 733, in _doCategoryChange
    newCat = self._getCategoryPanel(newCatId)
  File "gui\settingsDialogs.py", line 660, in _getCategoryPanel
    panel = cls(parent=self.container)
  File "gui\settingsDialogs.py", line 392, in __init__
    self._buildGui()
    ~~~~~~~~~~~~~~^^
  File "gui\settingsDialogs.py", line 402, in _buildGui
    self.makeSettings(self.settingsSizer)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "gui\settingsDialogs.py", line 2771, in makeSettings
    languageIndex = next(filter(lambda idxLang: idxLang[1].code == mathLang, self.languageOptions))[0]
                    ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "gui\settingsDialogs.py", line 2771, in <lambda>
    languageIndex = next(filter(lambda idxLang: idxLang[1].code == mathLang, self.languageOptions))[0]
                                                ~~~~~~~^^^
TypeError: 'LanguageInfo' object is not subscriptable
I

Description of user facing changes:

The math panel can be displayed again.

Description of developer facing changes:

None

Description of development approach:

  • Used enumerate on the language list to be able to retrieve its index.
  • Also used a generator expression instead of the use of the filter function + lambda since the previous code seemed less readable and less modern Python syntax. This is debatable though, and I can restore the old syntax, just adding enumerate, if you prefer.
  • Added a DEBUGWARNING log when the config language is not found in supported languages.

Testing strategy:

Manual tests:

  • Checked that the math panel displays, with language set to "Auto" and to "en" in config
  • Also tried to manually set language to "zz" in config and checked that the debug warning is logged and that Automatic is selected in the panel.

Known issues with pull request:

None

Code Review Checklist:

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

@CyrilleB79 CyrilleB79 requested a review from a team as a code owner March 20, 2026 14:17
@CyrilleB79 CyrilleB79 requested a review from seanbudd March 20, 2026 14:17
@CyrilleB79

Copy link
Copy Markdown
Contributor Author

System test chrome_annotations is failing; unrelated to this PR.

@seanbudd seanbudd added this to the 2026.1 milestone Mar 23, 2026

@seanbudd seanbudd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix @CyrilleB79

@seanbudd seanbudd merged commit 81122bf into nvaccess:beta Mar 23, 2026
37 of 39 checks passed
@CyrilleB79 CyrilleB79 deleted the fixMathPanel branch March 23, 2026 10:19
@brunoprietog

Copy link
Copy Markdown

Hi, I'm not sure if this is happening after this PR, but in today's latest alpha version, when I navigate through the MathCat options, I get the following error:

ERROR - unhandled exception (07:17:51.364) - MainThread (33624):
Traceback (most recent call last):
  File "gui\settingsDialogs.pyc", line 6386, in onCategoryChange
  File "gui\settingsDialogs.pyc", line 755, in onCategoryChange
  File "gui\settingsDialogs.pyc", line 738, in _doCategoryChange
  File "gui\settingsDialogs.pyc", line 665, in _getCategoryPanel
  File "gui\settingsDialogs.pyc", line 397, in __init__
  File "gui\settingsDialogs.pyc", line 407, in _buildGui
  File "gui\settingsDialogs.pyc", line 2799, in makeSettings
  File "gui\settingsDialogs.pyc", line 2799, in <lambda>
TypeError: 'LanguageInfo' object is not subscriptable

Also, not all of the previous options are displayed anymore.

When I click Apply or OK, I can no longer reopen the NVDA options again, and I get the following error saying that another panel is already open.

ERROR - unhandled exception (07:17:58.952) - MainThread (33624):
Traceback (most recent call last):
  File "gui\__init__.pyc", line 343, in onNVDASettingsCommand
  File "gui\blockAction.pyc", line 112, in funcWrapper
  File "gui\__init__.pyc", line 268, in popupSettingsDialog
  File "gui\settingsDialogs.pyc", line 179, in __new__
RuntimeError: Cannot open new settings dialog while instance still exists: <gui.settingsDialogs.NVDASettingsDialog object at 0x000001B88182E210>

On the other hand, if I press Esc instead of OK, NVDA restarts automatically.

Also, I’ve noticed that once you go through the MathCat options, the voice and language now appear at the beginning of any category, even if you’re not in the Math category. And in fact, the magnifier options also appear in the math options if you access them from the top. If you access the math options from the bottom, the remote access options appear instead. It’s as if the options from adjacent categories are being filtered into the math options.

And I don’t see the selected language actually being saved either. Even if I restart NVDA after selecting “Automatic,” I still don’t have any value selected there.

@CyrilleB79

Copy link
Copy Markdown
Contributor Author

@brunoprietog please provide the exact version number. Thanks.

@brunoprietog

Copy link
Copy Markdown

@CyrilleB79 the version is alpha-55200,69c1fa0b (2026.2.0.55200) thanks 🙏

@brunoprietog

Copy link
Copy Markdown

I think the version from that day didn't have this PR yet, I've now updated to alpha-55275,8d4e1994 (2026.2.0.55275) and I'm no longer seeing these erratic behaviors

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.

3 participants