Save editor doc before opening same in viewer (#1884)

This commit is contained in:
Veronica Berglyd Olsen
2024-05-29 21:26:29 +02:00
parent 931aed6d78
commit be7078aa7e
2 changed files with 4 additions and 9 deletions
-9
View File
@@ -245,9 +245,6 @@ class GuiDocViewer(QTextBrowser):
})
self.updateDocMargins()
# Since we change the content while it may still be rendering, we mark
# the document dirty again to make sure it's re-rendered properly.
self.redrawText()
QApplication.restoreOverrideCursor()
self.documentLoaded.emit(tHandle)
@@ -259,12 +256,6 @@ class GuiDocViewer(QTextBrowser):
self.loadText(self._docHandle, updateHistory=False)
return
def redrawText(self) -> None:
"""Redraw the text by marking the content as "dirty"."""
self.document().markContentsDirty(0, self.document().characterCount())
self.updateDocMargins()
return
def docAction(self, action: nwDocAction) -> bool:
"""Process document actions on the current document."""
logger.debug("Requesting action: '%s'", action.name)
+4
View File
@@ -616,6 +616,10 @@ class GuiMain(QMainWindow):
# Make sure main tab is in Editor view
self._changeView(nwView.EDITOR)
# If we're loading the document in the editor, it may need to be saved
if tHandle == self.docEditor.docHandle and self.docEditor.docChanged:
self.saveDocument()
logger.debug("Viewing document with handle '%s'", tHandle)
updateHistory = tHandle != self.docViewer.docHandle
if self.docViewer.loadText(tHandle, updateHistory=updateHistory):