Make sure a contentsChange signal is not emitted when document margins change

This commit is contained in:
Veronica K. B. Olsen
2019-11-19 10:36:43 +01:00
parent 1659d2a110
commit 78a8f5bb9c
+7 -1
View File
@@ -250,7 +250,7 @@ class GuiDocEditor(QTextEdit):
def updateDocMargins(self):
"""Automatically adjust the margins so the text is centred, but
only if Config.textFixedW is set to True.
only if Config.textFixedW is enabled or we're in Zen mode.
"""
if self.mainConf.textFixedW or self.theParent.isZenMode:
@@ -273,7 +273,13 @@ class GuiDocEditor(QTextEdit):
docFormat = self.qDocument.rootFrame().frameFormat()
docFormat.setLeftMargin(tM)
docFormat.setRightMargin(tM)
# Updating root frame triggers a QTextDocument->contentsChange
# signal, which we do not want as it re-runs the syntax
# highlighter and spell checker, so we block it briefly.
self.qDocument.blockSignals(True)
self.qDocument.rootFrame().setFrameFormat(docFormat)
self.qDocument.blockSignals(False)
return