From d21c8bad7335a90339d8cc48dbe8948c7f05bab3 Mon Sep 17 00:00:00 2001 From: Sean Budd Date: Mon, 4 Nov 2024 11:32:50 +1100 Subject: [PATCH] Provide speech symbols file name path on creation (#17346) 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. --- source/buildVersion.py | 2 +- source/characterProcessing.py | 6 +++--- user_docs/en/changes.md | 8 ++++++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/source/buildVersion.py b/source/buildVersion.py index 9bca9bcc1e8..4cc7d16436e 100644 --- a/source/buildVersion.py +++ b/source/buildVersion.py @@ -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" diff --git a/source/characterProcessing.py b/source/characterProcessing.py index cd62257f219..f0b8b096b93 100644 --- a/source/characterProcessing.py +++ b/source/characterProcessing.py @@ -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. @@ -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: diff --git a/user_docs/en/changes.md b/user_docs/en/changes.md index f9fdc4c43ab..eedce52bcf2 100644 --- a/user_docs/en/changes.md +++ b/user_docs/en/changes.md @@ -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.