Skip to content

Commit 345154a

Browse files
authored
Bugfix when resetting configuration (nvaccess#14894)
Fixes nvaccess#13187 Summary of the issue: After having modified a parameter in a profile and then reset it to its original value with NVDA+control+C, it was not possible to save the configuration with NVDA+control+R; NVDA was complaining that the file system was probably read-only. Description of user facing changes NVDA will no longer refuse to save the configuration after a configuration reset. Description of development approach Bugfix: when resetting the config, config.conf._dirtyProfiles is cleared I have also narrowed the exception filtering when saving the config since in nvaccess#13187, we get a message related to file write error, whereas the real error had nothing to do with it: it was a KeyError when trying to find "notepad" in config.conf._profileCache. I have filtered on PermissionError which is the error that I get when I set nvda.ini (or the whole NVDA setting folder) as read-only and try to save the config.
1 parent e77bde9 commit 345154a

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

source/config/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# A part of NonVisual Desktop Access (NVDA)
2-
# Copyright (C) 2006-2022 NV Access Limited, Aleksey Sadovoy, Peter Vágner, Rui Batista, Zahari Yurukov,
3-
# Joseph Lee, Babbage B.V., Łukasz Golonka, Julien Cochuyt
2+
# Copyright (C) 2006-2023 NV Access Limited, Aleksey Sadovoy, Peter Vágner, Rui Batista, Zahari Yurukov,
3+
# Joseph Lee, Babbage B.V., Łukasz Golonka, Julien Cochuyt, Cyrille Bougot
44
# This file is covered by the GNU General Public License.
55
# See the file COPYING for more details.
66

@@ -714,7 +714,7 @@ def save(self):
714714
self._writeProfileToFile(self._profileCache[name].filename, self._profileCache[name])
715715
log.info("Saved configuration profile %s" % name)
716716
self._dirtyProfiles.clear()
717-
except Exception as e:
717+
except PermissionError as e:
718718
log.warning("Error saving configuration; probably read only file system")
719719
log.debugWarning("", exc_info=True)
720720
raise e
@@ -728,6 +728,7 @@ def reset(self, factoryDefaults=False):
728728
pre_configReset.notify(factoryDefaults=factoryDefaults)
729729
self.profiles = []
730730
self._profileCache.clear()
731+
self._dirtyProfiles.clear()
731732
# Signal that we're initialising.
732733
self.rootSection = None
733734
self._initBaseConf(factoryDefaults=factoryDefaults)

source/gui/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def onSaveConfigurationCommand(self,evt):
155155
config.conf.save()
156156
# Translators: Reported when current configuration has been saved.
157157
queueHandler.queueFunction(queueHandler.eventQueue,ui.message,_("Configuration saved"))
158-
except:
158+
except PermissionError:
159159
# Translators: Message shown when current configuration cannot be saved such as when running NVDA from a CD.
160160
messageBox(_("Could not save configuration - probably read only file system"),_("Error"),wx.OK | wx.ICON_ERROR)
161161

user_docs/en/changes.t2t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ Instead NVDA reports that the link has no destination. (#14723)
6565
- In Windows 11, it is once again possible to open the Contributors and License items on the NVDA Help menu. (#14725)
6666
- When forcing UIA support with certain terminal and consoles, a bug is fixed which caused a freeze and the log file to be spammed. (#14689)
6767
- NVDA no longer fails to announce focusing password fields in Microsoft Excel and Outlook. (#14839)
68+
- NVDA will no longer refuse to save the configuration after a configuration reset. (#13187)
6869
-
6970

7071

0 commit comments

Comments
 (0)