Skip to content

Commit

Permalink
Plug memory leak
Browse files Browse the repository at this point in the history
Better setting document in editor to None instead of instantiating
a QTextDocument without parent.
  • Loading branch information
soininen committed Oct 16, 2024
1 parent a2a11c2 commit 787d521
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions spinetoolbox/widgets/code_text_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ def setPlainText(self, text):
self.setDocument(doc)

def setDocument(self, doc):
doc.setDocumentLayout(QPlainTextDocumentLayout(doc))
if doc is not None:
doc.setDocumentLayout(QPlainTextDocumentLayout(doc))
doc.setDefaultFont(self.font())
super().setDocument(doc)
self._highlighter.setDocument(doc)
doc.setDefaultFont(self.font())
self.setTabStopDistance(QFontMetrics(self.font()).horizontalAdvance(4 * " "))

def line_number_area_width(self):
Expand Down

0 comments on commit 787d521

Please sign in to comment.