Skip to content

Fix find/replace overlay asyncExecIfOpen running on disposed container#3999

Open
HeikoKlare wants to merge 1 commit into
eclipse-platform:masterfrom
HeikoKlare:fix/asyncExecIfOpen-disposed-container-check
Open

Fix find/replace overlay asyncExecIfOpen running on disposed container#3999
HeikoKlare wants to merge 1 commit into
eclipse-platform:masterfrom
HeikoKlare:fix/asyncExecIfOpen-disposed-container-check

Conversation

@HeikoKlare
Copy link
Copy Markdown
Contributor

@HeikoKlare HeikoKlare commented May 14, 2026

The inner guard in the find/replace overlay's asyncExecIfOpen used || instead of && and was missing the ! negation on isDisposed(). Since containerControl is never null, the condition always short-circuited to true, making the guard ineffective. This allowed updatePlacementAndVisibility to run on a disposed container, causing an SWTException: Widget is disposed.
This change fixes the condition so the operation only runs when the container is still alive.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 14, 2026

Test Results

   867 files  ±0     867 suites  ±0   1h 2m 54s ⏱️ + 1m 7s
 7 988 tests ±0   7 745 ✅ ±0  243 💤 ±0  0 ❌ ±0 
20 466 runs  ±0  19 811 ✅ ±0  655 💤 ±0  0 ❌ ±0 

Results for commit aeca635. ± Comparison against base commit b58e3b4.

♻️ This comment has been updated with latest results.

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.
@HeikoKlare HeikoKlare force-pushed the fix/asyncExecIfOpen-disposed-container-check branch from c394058 to aeca635 Compare May 14, 2026 07:47
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.

1 participant