Skip to content

Dispose SourceViewerDecorationSupport in QuickSearchDialog - #4220

Merged
merks merged 2 commits into
eclipse-platform:masterfrom
mx990:quick-search-dispose-viewer-decoration-support
Aug 5, 2026
Merged

Dispose SourceViewerDecorationSupport in QuickSearchDialog#4220
merks merged 2 commits into
eclipse-platform:masterfrom
mx990:quick-search-dispose-viewer-decoration-support

Conversation

@mx990

@mx990 mx990 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

The QuickSearchDialog did not dispose the SourceViewerDecorationSupport created in createViewerDecorations(), leading to a resource leak. This disposes SourceViewerDecorationSupport when closing the dialog.

@eclipse-platform-bot

Copy link
Copy Markdown
Contributor

This pull request changes some projects for the first time in this development cycle.
Therefore the following files need a version increment:

bundles/org.eclipse.text.quicksearch/META-INF/MANIFEST.MF

An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch.

Git patch
From 221b87f48ad337067f76ede9820ec22dbc2bcd63 Mon Sep 17 00:00:00 2001
From: Eclipse Platform Bot <platform-bot@eclipse.org>
Date: Mon, 3 Aug 2026 13:19:46 +0000
Subject: [PATCH] Version bump(s) for 4.41 stream


diff --git a/bundles/org.eclipse.text.quicksearch/META-INF/MANIFEST.MF b/bundles/org.eclipse.text.quicksearch/META-INF/MANIFEST.MF
index c81a682902..9bbeb36695 100644
--- a/bundles/org.eclipse.text.quicksearch/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.text.quicksearch/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.text.quicksearch;singleton:=true
-Bundle-Version: 1.3.500.qualifier
+Bundle-Version: 1.3.600.qualifier
 Bundle-Activator: org.eclipse.text.quicksearch.internal.ui.QuickSearchActivator
 Require-Bundle: org.eclipse.ui;bundle-version="[3.113.0,4.0.0)",
  org.eclipse.core.resources;bundle-version="[3.13.0,4.0.0)",
-- 
2.54.0

Further information are available in Common Build Issues - Missing version increments.

@merks merks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks correct to me.

@merks merks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I wonder about the dispose method being a better place.

https://github.com/mx990/eclipse.platform.ui/blob/4b21b7cdb91e96b34dc5c88db9d26b137b0948ba/bundles/org.eclipse.text.quicksearch/src/org/eclipse/text/quicksearch/internal/ui/QuickSearchDialog.java#L1022

Is it always the case that close is called, e.g., even if you it escape? Of course most of the other disposes are in close, so it's already a bit in a confusing state...

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Test Results

   858 files  ±0     858 suites  ±0   47m 19s ⏱️ -44s
 8 129 tests ±0   7 886 ✅ ±0  243 💤 ±0  0 ❌ ±0 
20 289 runs  ±0  19 635 ✅ ±0  654 💤 ±0  0 ❌ ±0 

Results for commit 4b21b7c. ± Comparison against base commit ae00a08.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a resource leak in the QuickSearch UI by ensuring SourceViewerDecorationSupport is properly tracked and disposed when the dialog is closed.

Changes:

  • Store SourceViewerDecorationSupport as a dialog field instead of a local variable.
  • Dispose the SourceViewerDecorationSupport instance during QuickSearchDialog#close().
  • Bump org.eclipse.text.quicksearch bundle version.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
bundles/org.eclipse.text.quicksearch/src/org/eclipse/text/quicksearch/internal/ui/QuickSearchDialog.java Track and dispose SourceViewerDecorationSupport to address a leak on dialog close.
bundles/org.eclipse.text.quicksearch/META-INF/MANIFEST.MF Increment bundle version to reflect the bug fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +585 to +588
if (sourceViewerDecorationSupport != null) {
sourceViewerDecorationSupport.dispose();
sourceViewerDecorationSupport = null;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed this is the fishy part. What else in close should actually be moved to dispose such that it's always done and always only once?

@merks merks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I take my approval back because while it looks correct, it only looks correct because other things are disposed in close, but I don't think that was correct before this change...

mx990 and others added 2 commits August 5, 2026 14:45
The QuickSearchDialog did not dispose the SourceViewerDecorationSupport
created in createViewerDecorations(), leading to a resource leak.
This disposes SourceViewerDecorationSupport in the dispose listener of
the dialog.

Furthermore, most resources were only disposed in close(), but not in
the separate dispose listener, which could also lead to a resource
leak when closing the dialog abnormally, such as when disposing the
Shell. This also moves the other cleanup code from close() to the
dispose listener.
@mx990
mx990 force-pushed the quick-search-dispose-viewer-decoration-support branch from 4b21b7c to 66b9e7c Compare August 5, 2026 12:49
@mx990

mx990 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

You are right, I was able to identify a case where close() is indeed not called. This happens, for example, when the Shell itself is disposed, which can easily be triggered when closing the workbench window. I have therefore moved all of the cleanup code to the dispose method.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@merks merks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks for consistent. I tested it in a self-host launch. I'm not sure in which case close is not called. Even when I hit esc it's called. But this does seem more logical and consistent.

@merks

merks commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Ah, I read your comment about when close is not called after I wrote my comment. 😁

@merks
merks merged commit 83485f7 into eclipse-platform:master Aug 5, 2026
17 checks passed
@mx990
mx990 deleted the quick-search-dispose-viewer-decoration-support branch August 5, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants