Fix circular reference issue between EditPredictionButton and PopoverMenuHandle (#42351)
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 <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/dc16897144700e4f949347e4ba7b8ef05c0b8efc/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/be5a67cbdac5c503aa2626d757c82f07484eeac4/crates/edit_prediction_button/src/edit_prediction_button.rs#L382-L389 https://github.com/zed-industries/zed/blob/edaf9e122cbd198eacfdb0041ddb6fdff438e620/crates/ui/src/components/popover_menu.rs#L376-L384 Release Notes: - N/A
This commit is contained in:
1 parent
39e48c0d88
commit
b9c705c72e
1 file changed
+3
-2
@@ -379,11 +379,12 @@ impl Render for EditPredictionButton {
|
||||
})
|
||||
});
|
||||
|
||||
let this = cx.entity();
|
||||
let this = cx.weak_entity();
|
||||
|
||||
let mut popover_menu = PopoverMenu::new("zeta")
|
||||
.menu(move |window, cx| {
|
||||
Some(this.update(cx, |this, cx| this.build_zeta_context_menu(window, cx)))
|
||||
this.update(cx, |this, cx| this.build_zeta_context_menu(window, cx))
|
||||
.ok()
|
||||
})
|
||||
.anchor(Corner::BottomRight)
|
||||
.with_handle(self.popover_menu_handle.clone());
|
||||
|
||||
Reference in new issue
Block a user