Keep the ExtraSelection object around to prevent garbage collector race and segfault
This commit is contained in:
@@ -147,6 +147,7 @@ class GuiDocEditor(QPlainTextEdit):
|
|||||||
self._lastFind = None # Position of the last found search word
|
self._lastFind = None # Position of the last found search word
|
||||||
self._doReplace = False # Switch to temporarily disable auto-replace
|
self._doReplace = False # Switch to temporarily disable auto-replace
|
||||||
self._lineColor = QtTransparent
|
self._lineColor = QtTransparent
|
||||||
|
self._selection = QTextEdit.ExtraSelection()
|
||||||
|
|
||||||
# Auto-Replace
|
# Auto-Replace
|
||||||
self._autoReplace = TextAutoReplace()
|
self._autoReplace = TextAutoReplace()
|
||||||
@@ -321,6 +322,8 @@ class GuiDocEditor(QPlainTextEdit):
|
|||||||
self.docFooter.matchColors()
|
self.docFooter.matchColors()
|
||||||
|
|
||||||
self._lineColor = syntax.line
|
self._lineColor = syntax.line
|
||||||
|
self._selection.format.setBackground(self._lineColor)
|
||||||
|
self._selection.format.setProperty(QTextFormat.Property.FullWidthSelection, True)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -1314,12 +1317,9 @@ class GuiDocEditor(QPlainTextEdit):
|
|||||||
def _highlightCurrentLine(self) -> None:
|
def _highlightCurrentLine(self) -> None:
|
||||||
"""Highlight the cursor line if setting is enabled."""
|
"""Highlight the cursor line if setting is enabled."""
|
||||||
if CONFIG.lineHighlight:
|
if CONFIG.lineHighlight:
|
||||||
selection = QTextEdit.ExtraSelection()
|
self._selection.cursor = self.textCursor()
|
||||||
selection.format.setBackground(self._lineColor)
|
self._selection.cursor.clearSelection()
|
||||||
selection.format.setProperty(QTextFormat.Property.FullWidthSelection, True)
|
self.setExtraSelections([self._selection])
|
||||||
selection.cursor = self.textCursor()
|
|
||||||
selection.cursor.clearSelection()
|
|
||||||
self.setExtraSelections([selection])
|
|
||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|||||||
Reference in New Issue
Block a user