Add a method in the shared object to ensure document editor is saved
This commit is contained in:
@@ -204,6 +204,19 @@ class SharedData(QObject):
|
|||||||
self._resetIdleTimer()
|
self._resetIdleTimer()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def ensureEditorSaved(self, tHandle: str | None) -> None:
|
||||||
|
"""Ensure that the editor content is saved. Optionally, only if
|
||||||
|
it is a specific handle.
|
||||||
|
"""
|
||||||
|
docEditor = self.mainGui.docEditor
|
||||||
|
if (
|
||||||
|
self.hasProject and docEditor.docHandle
|
||||||
|
and (tHandle is None or tHandle == docEditor.docHandle)
|
||||||
|
):
|
||||||
|
logger.debug("Saving editor document before action")
|
||||||
|
docEditor.saveText()
|
||||||
|
return
|
||||||
|
|
||||||
def updateSpellCheckLanguage(self, reload: bool = False) -> None:
|
def updateSpellCheckLanguage(self, reload: bool = False) -> None:
|
||||||
"""Update the active spell check language from settings."""
|
"""Update the active spell check language from settings."""
|
||||||
from novelwriter import CONFIG
|
from novelwriter import CONFIG
|
||||||
|
|||||||
@@ -343,7 +343,7 @@ class GuiManuscript(NDialog):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Make sure editor content is saved before we start
|
# Make sure editor content is saved before we start
|
||||||
SHARED.mainGui.saveDocument()
|
SHARED.ensureEditorSaved(None)
|
||||||
|
|
||||||
docBuild = NWBuildDocument(SHARED.project, build)
|
docBuild = NWBuildDocument(SHARED.project, build)
|
||||||
docBuild.setPreviewMode(True)
|
docBuild.setPreviewMode(True)
|
||||||
|
|||||||
Reference in New Issue
Block a user