Skip to content

Commit

Permalink
Provide speech symbols file name path on creation (#17346)
Browse files Browse the repository at this point in the history
Fixes #17344

Summary of the issue:
The SpeechSymbols only sets the filename to write to when the dictionary is loaded.
Before 826ef91, dictionary files were always loaded before they were saved.
Afterwards, dictionaries are saved without being loaded.
When trying to save dictionary files the following error occurs, due to no file name being set

Speaking [LangChangeCommand ('en_US'), 'pressed']
ERROR - unhandled exception (17:00:20.842) - MainThread (9964):
Traceback (most recent call last):
  File "gui\settingsDialogs.pyc", line 5350, in onOk
  File "characterProcessing.pyc", line 364, in save
ValueError: No file name
Description of user facing changes
Users can now save the speech dictionary dialog.
Add-ons which use custom speech dictionaries are also saved correctly now.

Description of development approach
Create optional parameter to set filename path for speech dictionaries.
  • Loading branch information
seanbudd authored Nov 4, 2024
1 parent 57923e2 commit d21c8ba
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion source/buildVersion.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def formatVersionForGUI(year, major, minor):
name = "NVDA"
version_year = 2024
version_major = 4
version_minor = 0
version_minor = 1
version_build = 0 # Should not be set manually. Set in 'sconscript' provided by 'appVeyor.yml'
version = _formatDevVersionString()
publisher = "unknown"
Expand Down
6 changes: 3 additions & 3 deletions source/characterProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,11 @@ class SpeechSymbols:
This is all handled by L{SpeechSymbolProcessor}.
"""

def __init__(self):
def __init__(self, filename: str | None = None):
"""Constructor."""
self.complexSymbols = collections.OrderedDict()
self.symbols = collections.OrderedDict()
self.fileName = None
self.fileName = filename

def load(self, fileName: str, allowComplexSymbols: bool = True) -> None:
"""Load symbol information from a file.
Expand Down Expand Up @@ -826,7 +826,7 @@ def getSymbols(self, locale: str) -> SpeechSymbols:

def _initSymbols(self, locale: str) -> SpeechSymbols:
raiseOnError = self.source != _SymbolDefinitionSource.USER
symbols = SpeechSymbols()
symbols = SpeechSymbols(self.path.format(locale=locale))
if locale not in self.availableLocales:
msg = f"No {self.name!r} data for locale {locale!r}"
if raiseOnError:
Expand Down
8 changes: 8 additions & 0 deletions user_docs/en/changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# What's New in NVDA

## 2024.4.1

It also includes a fix for saving speech symbol dictionaries.

### Bug fixes

* Fixed bug where speech symbols dictionaries were not saved and the dialog would not be closed. (#17344)

## 2024.4

This release includes a number of improvements in Microsoft Office, braille, and document formatting.
Expand Down

0 comments on commit d21c8ba

Please sign in to comment.