Skip to content

Commit b75a423

Browse files
authored
Merge 977480b into f24911c
2 parents f24911c + 977480b commit b75a423

6 files changed

Lines changed: 45 additions & 29 deletions

File tree

source/NVDAHelper.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import winreg
1010
import msvcrt
1111
import winVersion
12-
import versionInfo
12+
import buildVersion
1313
import winKernel
1414
import config
1515

@@ -39,9 +39,9 @@
3939

4040
if not NVDAState.isRunningAsSource():
4141
# When running as a py2exe build, libraries are in a version-specific directory
42-
versionedLibPath=os.path.join(versionedLibPath,versionInfo.version)
43-
versionedLibAMD64Path = os.path.join(versionedLibAMD64Path, versionInfo.version)
44-
versionedLibARM64Path = os.path.join(versionedLibARM64Path, versionInfo.version)
42+
versionedLibPath = os.path.join(versionedLibPath, buildVersion.version)
43+
versionedLibAMD64Path = os.path.join(versionedLibAMD64Path, buildVersion.version)
44+
versionedLibARM64Path = os.path.join(versionedLibARM64Path, buildVersion.version)
4545

4646

4747
_remoteLib=None

source/config/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,10 @@ def _loadConfig(self, fn, fileError=False):
585585
profile.newlines = "\r\n"
586586
profileCopy = deepcopy(profile)
587587
try:
588-
writeProfileFunc = self._writeProfileToFile if NVDAState.shouldWriteToDisk() else None
588+
if NVDAState.shouldWriteToDisk() and profile.filename is not None:
589+
writeProfileFunc = self._writeProfileToFile
590+
else:
591+
writeProfileFunc = None
589592
profileUpgrader.upgrade(profile, self.validator, writeProfileFunc)
590593
except Exception as e:
591594
# Log at level info to ensure that the profile is logged.
@@ -700,8 +703,7 @@ def save(self):
700703
log.info("Saved configuration profile %s" % name)
701704
self._dirtyProfiles.clear()
702705
except PermissionError as e:
703-
log.warning("Error saving configuration; probably read only file system")
704-
log.debugWarning("", exc_info=True)
706+
log.warning("Error saving configuration; probably read only file system", exc_info=True)
705707
raise e
706708
post_configSave.notify()
707709

source/config/profileUpgrader.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
# -*- coding: UTF-8 -*-
2-
#A part of NonVisual Desktop Access (NVDA)
3-
#Copyright (C) 2016 NV Access Limited
4-
#This file is covered by the GNU General Public License.
5-
#See the file COPYING for more details.
1+
# A part of NonVisual Desktop Access (NVDA)
2+
# Copyright (C) 2016-2023 NV Access Limited, Cyrille Bougot
3+
# This file is covered by the GNU General Public License.
4+
# See the file COPYING for more details.
65

76
from logHandler import log
87
from .configSpec import latestSchemaVersion, confspec
@@ -28,10 +27,8 @@ def upgrade(profile, validator, writeProfileToFileFunc):
2827
# other reason the file does not need to be upgraded again.
2928
if writeProfileToFileFunc:
3029
writeProfileToFileFunc(profile.filename, profile)
31-
except Exception as e:
32-
log.warning("Error saving configuration; probably read only file system")
33-
log.debugWarning("", exc_info=True)
34-
pass
30+
except PermissionError:
31+
log.warning("Error saving configuration; probably read only file system", exc_info=True)
3532

3633
def _doConfigUpgrade(profile, fromVersion):
3734
toVersion = fromVersion+1

source/logHandler.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# A part of NonVisual Desktop Access (NVDA)
22
# Copyright (C) 2007-2023 NV Access Limited, Rui Batista, Joseph Lee, Leonard de Ruijter, Babbage B.V.,
3-
# Accessolutions, Julien Cochuyt
3+
# Accessolutions, Julien Cochuyt, Cyrille Bougot
44
# This file is covered by the GNU General Public License.
55
# See the file COPYING for more details.
66

@@ -141,15 +141,21 @@ def getCodePath(f):
141141
return ".".join(x for x in (path,className,funcName) if x)
142142

143143

144+
_onErrorLogged = None
145+
146+
147+
def getOnErrorLogged():
148+
global _onErrorLogged
149+
150+
import extensionPoints
151+
if not _onErrorLogged:
152+
_onErrorLogged = extensionPoints.Action()
153+
return _onErrorLogged
154+
155+
144156
def shouldPlayErrorSound() -> bool:
145157
"""Indicates if an error sound should be played when an error is logged.
146158
"""
147-
import nvwave
148-
if nvwave.isInError():
149-
if nvwave._isDebugForNvWave():
150-
log.debug("No beep for log; nvwave is in error state")
151-
return False
152-
153159
import config
154160
# Only play the error sound if this is a test version or if the config states it explicitly.
155161
return (
@@ -347,11 +353,7 @@ def handle(self,record):
347353
except:
348354
pass
349355
elif record.levelno >= logging.ERROR and shouldPlayErrorSound():
350-
import nvwave
351-
try:
352-
nvwave.playWaveFile(os.path.join(globalVars.appDir, "waves", "error.wav"))
353-
except:
354-
pass
356+
getOnErrorLogged().notify()
355357
return super().handle(record)
356358

357359
class Formatter(logging.Formatter):

source/nvwave.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,12 @@
4545
import winKernel
4646
import wave
4747
import config
48-
from logHandler import log
48+
from logHandler import log, getOnErrorLogged
4949
import os.path
5050
import extensionPoints
5151
import NVDAHelper
5252
import core
53+
import globalVars
5354

5455

5556
__all__ = (
@@ -1056,6 +1057,7 @@ def _deviceNameToId(name, fallbackToDefault=True):
10561057
def initialize():
10571058
global WavePlayer
10581059
if not config.conf["audio"]["WASAPI"]:
1060+
getOnErrorLogged().register(playErrorSound)
10591061
return
10601062
WavePlayer = WasapiWavePlayer
10611063
NVDAHelper.localLib.wasPlay_create.restype = c_void_p
@@ -1073,7 +1075,19 @@ def initialize():
10731075
func.restype = HRESULT
10741076
func.errcheck = _wasPlay_errcheck
10751077
NVDAHelper.localLib.wasPlay_startup()
1078+
getOnErrorLogged().register(playErrorSound)
10761079

10771080

10781081
def usingWasapiWavePlayer() -> bool:
10791082
return issubclass(WavePlayer, WasapiWavePlayer)
1083+
1084+
1085+
def playErrorSound():
1086+
if isInError():
1087+
if _isDebugForNvWave():
1088+
log.debug("No beep for log; nvwave is in error state")
1089+
return
1090+
try:
1091+
playWaveFile(os.path.join(globalVars.appDir, "waves", "error.wav"))
1092+
except Exception:
1093+
pass

user_docs/en/changes.t2t

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ This makes the announcement of spelling errors work when announcing a line in Wr
4343
It is also updated with UIA enabled, when typing text and braille is tethered to review and review follows caret. (#3276)
4444
- Multi line braille displays will no longer crash the BRLTTY driver and are treated as one continuous display. (#15386)
4545
- NVDA no longer sometimes freezes briefly when multiple sounds are played in rapid succession. (#15311)
46+
- NVDA will not fail to start anymore when the configuration file is corrupted, but it will restore the configuration to default as it did in the past. (#15690, @CyrilleB79)
4647
-
4748

4849
== Changes for Developers ==

0 commit comments

Comments
 (0)