Fix issues discovered when testing

This commit is contained in:
Veronica Berglyd Olsen
2023-09-01 17:34:34 +02:00
parent 03c4b91682
commit 9c7663996c
4 changed files with 23 additions and 12 deletions
+1 -1
View File
@@ -600,7 +600,7 @@ class NWProject:
self._langData = json.load(inFile)
logger.debug("Loaded project language file: %s", langFile.name)
except Exception:
logger.error("Failed to project language file")
logger.error("Failed to load project language file")
logException()
return False
+4 -4
View File
@@ -36,7 +36,6 @@ from functools import partial
from PyQt5.QtCore import QCoreApplication, QRegularExpression
from novelwriter import SHARED
from novelwriter.enum import nwItemLayout
from novelwriter.common import formatTimeStamp, numberToRoman, checkInt
from novelwriter.constants import nwConst, nwHeadFmt, nwRegEx, nwUnicode
@@ -148,7 +147,7 @@ class Tokenizer(ABC):
self._linkHeaders = False # Add an anchor before headers
# Instance Variables
self._hFormatter = HeadingFormatter()
self._hFormatter = HeadingFormatter(self._project)
self._firstScene = False # Flag to indicate that the first scene of the chapter
# This File
@@ -772,7 +771,8 @@ class Tokenizer(ABC):
class HeadingFormatter:
def __init__(self) -> None:
def __init__(self, project: NWProject) -> None:
self._project = project
self._chCount = 0
self._scChCount = 0
self._scAbsCount = 0
@@ -801,7 +801,7 @@ class HeadingFormatter:
hFormat = hFormat.replace(nwHeadFmt.SC_NUM, str(self._scChCount))
hFormat = hFormat.replace(nwHeadFmt.SC_ABS, str(self._scAbsCount))
if nwHeadFmt.CH_WORD in hFormat:
chWord = SHARED.project.localLookup(self._chCount)
chWord = self._project.localLookup(self._chCount)
hFormat = hFormat.replace(nwHeadFmt.CH_WORD, chWord)
if nwHeadFmt.CH_ROML in hFormat:
chRom = numberToRoman(self._chCount, toLower=True)
+5 -4
View File
@@ -290,9 +290,10 @@ class GuiManuscript(QDialog):
@pyqtSlot("QListWidgetItem*", "QListWidgetItem*")
def _updateBuildDetails(self, current: QListWidgetItem, previous: QListWidgetItem) -> None:
"""Process change of build selection to update the details."""
build = self._builds.getBuild(current.data(self.D_KEY))
if build is not None:
self.buildDetails.updateInfo(build)
if isinstance(current, QListWidgetItem):
build = self._builds.getBuild(current.data(self.D_KEY))
if build is not None:
self.buildDetails.updateInfo(build)
return
@pyqtSlot()
@@ -586,7 +587,7 @@ class _DetailsWidget(QWidget):
item.addChild(sub)
# Headings
hFmt = HeadingFormatter()
hFmt = HeadingFormatter(SHARED.project)
hFmt.incChapter()
hFmt.incScene()
hFmt.resetScene()