Save editor doc before opening same in viewer (#1884)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user