From 2c0904e3853d249db21be3a97825ab7593b16a67 Mon Sep 17 00:00:00 2001 From: Andrey Loskutov Date: Wed, 8 Oct 2025 17:21:47 +0200 Subject: [PATCH] Remove document listener from document on handleDispose() UpdateDocumentListener is added to document but not always removed in ProjectionViewer, regression introduced by commit https://github.com/eclipse-platform/eclipse.platform.ui/commit/1848058a52102b5deff39427365e56fe882656b3 This fixes only one possible leak, where a single document was used in ProjectionViewer, to unblock JDT UI tests. Fixes https://github.com/eclipse-jdt/eclipse.jdt.ui/issues/2532 --- .../jface/text/source/projection/ProjectionViewer.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bundles/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java b/bundles/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java index 50fbf0e1654..a99a85541dd 100644 --- a/bundles/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java +++ b/bundles/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java @@ -1480,6 +1480,12 @@ private boolean willAutoExpand(Position position, int offset, int length) { @Override protected void handleDispose() { fWasProjectionEnabled= false; + if (fUpdateDocumentListener != null) { + IDocument document= getDocument(); + if (document != null) { + document.removeDocumentListener(fUpdateDocumentListener); + } + } super.handleDispose(); }