Skip to content

Commit 3913243

Browse files
committed
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.
1 parent 132e20a commit 3913243

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay

bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceOverlay.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ private void performSelectAll() {
352352
private void asyncExecIfOpen(Runnable operation) {
353353
if (!containerControl.isDisposed()) {
354354
containerControl.getDisplay().asyncExec(() -> {
355-
if (containerControl != null || containerControl.isDisposed()) {
355+
if (containerControl != null && !containerControl.isDisposed()) {
356356
operation.run();
357357
}
358358
});

0 commit comments

Comments
 (0)