Fix find/replace overlay asyncExecIfOpen running on disposed container#3999
Open
HeikoKlare wants to merge 1 commit into
Open
Conversation
Contributor
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.
c394058 to
aeca635
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The inner guard in the find/replace overlay's
asyncExecIfOpenused||instead of&&and was missing the!negation onisDisposed(). SincecontainerControlis nevernull, the condition always short-circuited totrue, making the guard ineffective. This allowedupdatePlacementAndVisibilityto run on a disposed container, causing anSWTException: Widget is disposed.This change fixes the condition so the operation only runs when the container is still alive.