Skip to content

Commit

Permalink
Fix issue with saving config and FeatureFlags (#15074)
Browse files Browse the repository at this point in the history
Fixes #14760
Fixup of #14133

Summary of the issue:
When saving a config spec, validation would be skipped if the string value of the data is unchanged.

This caused various issues including config values not being correctly converted to numbers from strings when validating.
This caused config profiles to fail to load or save correctly.

Description of user facing changes
Fix up of various bugs related to user config

Description of development approach
Perform special handling that was introduced in #14133 for feature flags only
  • Loading branch information
seanbudd committed Jul 3, 2023
1 parent 3a9a205 commit f6ee244
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 12 deletions.
13 changes: 9 additions & 4 deletions source/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from .featureFlag import (
_transformSpec_AddFeatureFlagDefault,
_validateConfig_featureFlag,
FeatureFlag,
)
from typing import (
Any,
Expand Down Expand Up @@ -1247,13 +1248,17 @@ def __setitem__(
except KeyError:
pass
else:
if self._isSection(val) or self._isSection(curVal):
# If value is a section, continue to update
pass
elif str(val) == str(curVal):
if (
# Feature flags override __eq__.
# Check str comparison as this is what is written to the config.
# If the value is unchanged, do not update
# or mark the profile as dirty.
(
isinstance(val, FeatureFlag)
or isinstance(curVal, FeatureFlag)
)
and str(val) == str(curVal)
):
return

# Set this value in the most recently activated profile.
Expand Down
4 changes: 2 additions & 2 deletions source/synthDrivers/espeak.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,10 @@ def _set_inflection(self,val):
val=self._percentToParam(val, _espeak.minPitch, _espeak.maxPitch)
_espeak.setParameter(_espeak.espeakRANGE,val,0)

def _get_volume(self):
def _get_volume(self) -> int:
return _espeak.getParameter(_espeak.espeakVOLUME,1)

def _set_volume(self,volume):
def _set_volume(self, volume: int):
_espeak.setParameter(_espeak.espeakVOLUME,volume,0)

def _getAvailableVoices(self):
Expand Down
10 changes: 5 additions & 5 deletions source/synthDrivers/oneCore.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ def __init__(self):
# Set initial values for parameters that can't be queried when prosody is not supported.
# This initialises our cache for the value.
# When prosody is supported, the values are used for cachign reasons.
self._rate = 50
self._pitch = 50
self._volume = 100
self._rate: int = 50
self._pitch: int = 50
self._volume: int = 100

if self.supportsProsodyOptions:
self._dll.ocSpeech_getPitch.restype = ctypes.c_double
Expand Down Expand Up @@ -339,13 +339,13 @@ def _set_pitch(self, pitch):
rawPitch = self._percentToParam(pitch, self.MIN_PITCH, self.MAX_PITCH)
self._queuedSpeech.append((self._dll.ocSpeech_setPitch, rawPitch))

def _get_volume(self):
def _get_volume(self) -> int:
if not self.supportsProsodyOptions:
return self._volume
rawVolume = self._dll.ocSpeech_getVolume(self._ocSpeechToken)
return int(rawVolume * 100)

def _set_volume(self, volume):
def _set_volume(self, volume: int):
self._volume = volume
if not self.supportsProsodyOptions:
return
Expand Down
2 changes: 1 addition & 1 deletion source/synthDrivers/sapi5.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def _get_rate(self):
def _get_pitch(self):
return self._pitch

def _get_volume(self):
def _get_volume(self) -> int:
return self.tts.volume

def _get_voice(self):
Expand Down
1 change: 1 addition & 0 deletions user_docs/en/changes.t2t
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ Also ``space+dot1`` and ``space+dot4`` now map to up and down arrow respectively
- When rapidly moving through cells in Excel, NVDA is now less likely to report the wrong cell or selection. (#14983, #12200, #12108)
- NVDA now generally responds slightly faster to commands and focus changes. (#14928)
- Displaying the OCR settings will not fail on some systems anymore. (#15017)
- Fix bug related to saving and loading the NVDA configuration, including switching synthesizers. (#14760)
-


Expand Down

0 comments on commit f6ee244

Please sign in to comment.