From fca5ea0897e84e54ac142e744ed9195013cfd3bc Mon Sep 17 00:00:00 2001 From: Ales Erjavec Date: Fri, 8 Mar 2024 09:46:57 +0100 Subject: [PATCH] ... gc --- Orange/widgets/data/utils/pythoneditor/editor.py | 3 +++ Orange/widgets/data/utils/pythoneditor/tests/base.py | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Orange/widgets/data/utils/pythoneditor/editor.py b/Orange/widgets/data/utils/pythoneditor/editor.py index 83c78680733..c75646c5529 100644 --- a/Orange/widgets/data/utils/pythoneditor/editor.py +++ b/Orange/widgets/data/utils/pythoneditor/editor.py @@ -58,6 +58,7 @@ def iterateBlocksBackFrom(block): def clear_extra_selections(selections: List[QTextEdit.ExtraSelection]): for s in selections: s.cursor = QTextCursor() + s.format = QTextCharFormat() class PythonEditor(QPlainTextEdit): @@ -981,6 +982,8 @@ def terminate(self): if self._vim is not None: self._vim.terminate() + clear_extra_selections(self._userExtraSelections) + self._userExtraSelections.clear() def __enter__(self): """Context management method. diff --git a/Orange/widgets/data/utils/pythoneditor/tests/base.py b/Orange/widgets/data/utils/pythoneditor/tests/base.py index dcfffd1d9cc..c1505f05b80 100644 --- a/Orange/widgets/data/utils/pythoneditor/tests/base.py +++ b/Orange/widgets/data/utils/pythoneditor/tests/base.py @@ -27,9 +27,11 @@ def setUp(self) -> None: def tearDown(self) -> None: self.qpart.terminate() - delete(self.qpart) - del self.qpart + # QTextEdit.ExtraSelection instances still remain ref cycles. + # They need to be released before the editor widget as they + # contain text cursors with C pointers to the widget's contents gc.collect() + del self.qpart super().tearDown()