From 4a20a0eb017493b862be95cdebb2a701fb0f1971 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Tue, 18 Aug 2020 08:50:08 +0200 Subject: [PATCH] Use markContentsDirty on the QTextDocument instead of the textWidth hack --- nw/gui/build.py | 7 +++---- nw/gui/docviewer.py | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/nw/gui/build.py b/nw/gui/build.py index 0370e23c..b61dfd0f 100644 --- a/nw/gui/build.py +++ b/nw/gui/build.py @@ -1037,10 +1037,9 @@ class GuiBuildNovelDocView(QTextBrowser): self.verticalScrollBar().setValue(sPos) self._updateBuildAge() - # This forces a repaint of the text, It's a hack to fix an occational - # issue where the find/replace above interfers with the rendering and - # leaves parts of the document blank. - self.qDocument.setTextWidth(self.qDocument.textWidth()) + # 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.qDocument.markContentsDirty(0, self.qDocument.characterCount()) return diff --git a/nw/gui/docviewer.py b/nw/gui/docviewer.py index 63a41e9b..b613ac2f 100644 --- a/nw/gui/docviewer.py +++ b/nw/gui/docviewer.py @@ -180,10 +180,9 @@ class GuiDocViewer(QTextBrowser): # Make sure the main GUI knows we changed the content self.theParent.viewMeta.refreshReferences(tHandle) - # This forces a repaint of the text, It's a hack to fix an occational - # issue where the find/replace above interfers with the rendering and - # leaves parts of the document blank. - self.qDocument.setTextWidth(self.qDocument.textWidth()) + # 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.qDocument.markContentsDirty(0, self.qDocument.characterCount()) return True