Fix circular reference issue between EditPredictionButton and PopoverMenuHandle#42351
Merged
SomeoneToIgnore merged 2 commits intozed-industries:mainfrom Nov 10, 2025
Merged
Fix circular reference issue between EditPredictionButton and PopoverMenuHandle#42351SomeoneToIgnore merged 2 commits intozed-industries:mainfrom
SomeoneToIgnore merged 2 commits intozed-industries:mainfrom
Conversation
SomeoneToIgnore
approved these changes
Nov 10, 2025
Contributor
SomeoneToIgnore
left a comment
There was a problem hiding this comment.
Superb, thank you so much for all the context and a fix.
I've found a fixed a few of these myself, so I suspect this might not be the last one around.
Not yet sure what to do about a systematic way to fix this, but any other similar fixes are very welcome.
Contributor
Author
|
Perhaps we could check if key objects, such as Project/Workspace, are properly released after the project closure? |
Contributor
Workspace isn't necessary going to be released, as technically, workspace == window and can be reused. |
SomeoneToIgnore
pushed a commit
that referenced
this pull request
Nov 11, 2025
Follow up to #42351 Release Notes: - N/A
11happy
pushed a commit
to 11happy/zed
that referenced
this pull request
Dec 1, 2025
…MenuHandle (zed-industries#42351) Closes #ISSUE While working on issue zed-industries#40906, I discovered that RemoteClient was not being released after the remote project closed. Analysis revealed a circular reference between EditPredictionButton and PopoverMenuHandle. Dependency Chain: RemoteClient → Project → ZetaEditPredictionProvider → EditPredictionButton ↔ PopoverMenuHandle <img width="400" height="300" alt="image" src="https://github.com/user-attachments/assets/6b716c9b-6938-471a-b044-397314b729d4" /> a) EditPredictionButton hold the reference of PopoverMenuHandle https://github.com/zed-industries/zed/blob/5f8226457ee6e1346a224ae6b0329f014ea883f7/crates/zed/src/zed.rs#L386-L394 b) PopoverMenuHandle hold the reference of Fn which capture `Entity<EditPredictionButton>` https://github.com/zed-industries/zed/blob/5fc54986c72f2863645302c5e6a99277f8c38cab/crates/edit_prediction_button/src/edit_prediction_button.rs#L382-L389 https://github.com/zed-industries/zed/blob/a9bc890497f1edaf4f177385cf96785de60e910c/crates/ui/src/components/popover_menu.rs#L376-L384 Release Notes: - N/A
11happy
pushed a commit
to 11happy/zed
that referenced
this pull request
Dec 1, 2025
Follow up to zed-industries#42351 Release Notes: - N/A
SomeoneToIgnore
pushed a commit
that referenced
this pull request
Dec 3, 2025
Follow up to #42351 Release Notes: - N/A
CherryWorm
pushed a commit
to CherryWorm/zed
that referenced
this pull request
Dec 16, 2025
…#44084) Follow up to zed-industries#42351 Release Notes: - N/A
someone13574
pushed a commit
to someone13574/zed
that referenced
this pull request
Dec 16, 2025
…#44084) Follow up to zed-industries#42351 Release Notes: - N/A
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.
Closes #ISSUE
While working on issue #40906, I discovered that RemoteClient was not being released after the remote project closed.
Analysis revealed a circular reference between EditPredictionButton and PopoverMenuHandle.
Dependency Chain: RemoteClient → Project → ZetaEditPredictionProvider → EditPredictionButton ↔ PopoverMenuHandle
a) EditPredictionButton hold the reference of PopoverMenuHandle
zed/crates/zed/src/zed.rs
Lines 386 to 394 in 5f82264
b) PopoverMenuHandle hold the reference of Fn which capture
Entity<EditPredictionButton>zed/crates/edit_prediction_button/src/edit_prediction_button.rs
Lines 382 to 389 in 5fc5498
zed/crates/ui/src/components/popover_menu.rs
Lines 376 to 384 in a9bc890
Release Notes: