From aeca6355a5ac1f8ce096d848d0976a2c33c39134 Mon Sep 17 00:00:00 2001 From: Heiko Klare Date: Thu, 14 May 2026 08:34:55 +0200 Subject: [PATCH] Fix find/replace overlay asyncExecIfOpen running on disposed container The inner guard inside the asyncExec callback of the find/replace overlay's asyncExecIfOpen method used || instead of && and was missing the negation on isDisposed(). Because containerControl is an instance field set once at construction and never cleared, the sub-expression `containerControl != null` is unconditionally true. Combined with || this caused the entire condition to always short-circuit to true, making the isDisposed() branch dead code and the guard ineffective. As a result, the async callback could invoke operation.run() even after containerControl had been disposed in the window between the outer check and the callback executing. The sole caller passes FindReplaceOverlay::updatePlacementAndVisibility, which calls requestLayout(), setSize(), setLocation() and layout() directly on containerControl. Executing those calls on a disposed widget throws an SWTException ("Widget is disposed"). Fix by changing the condition to `containerControl != null && !containerControl.isDisposed()`, which correctly re-checks liveness before running the operation. --- .../ui/internal/findandreplace/overlay/FindReplaceOverlay.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceOverlay.java b/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceOverlay.java index ed8ae54e416..ac389fd96a6 100644 --- a/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceOverlay.java +++ b/bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceOverlay.java @@ -352,7 +352,7 @@ private void performSelectAll() { private void asyncExecIfOpen(Runnable operation) { if (!containerControl.isDisposed()) { containerControl.getDisplay().asyncExec(() -> { - if (containerControl != null || containerControl.isDisposed()) { + if (containerControl != null && !containerControl.isDisposed()) { operation.run(); } });