Make a few minor improvements, including fixing #1495

This commit is contained in:
Veronica Berglyd Olsen
2023-08-20 22:09:02 +02:00
parent ed3e4bca6c
commit 55423174ed
4 changed files with 18 additions and 19 deletions
+9 -9
View File
@@ -213,15 +213,15 @@ class UserDictionary:
def load(self) -> None:
"""Load the user's dictionary."""
self._path = self._project.storage.getMetaFile(nwFiles.DICT_FILE)
if not isinstance(self._path, Path):
return
try:
with open(self._path, mode="r", encoding="utf-8") as fObj:
data = json.load(fObj)
self._words = set(data.get("novelWriter.userDict", []))
except Exception:
logger.error("Failed to load user dictionary")
logException()
self._words = set()
if isinstance(self._path, Path) and self._path.is_file():
try:
with open(self._path, mode="r", encoding="utf-8") as fObj:
data = json.load(fObj)
self._words = set(data.get("novelWriter.userDict", []))
except Exception:
logger.error("Failed to load user dictionary")
logException()
return
def save(self) -> None: