Rust generator: don't run the init code twice for popups (#6447)

Don't run the `init=>` callback in popup twice

ChangeLog: rust: Fixed `init=>` callback on PopupWindow ran twice.
This commit is contained in:
Olivier Goffart 2024-10-04 17:17:36 +02:00 committed by GitHub
parent 054035d930
commit 04e03ed197
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 20 deletions

View file

@ -1442,20 +1442,6 @@ fn generate_item_tree(
quote!(sp::Rc::new(SharedGlobals::new(sp::VRc::downgrade(&self_dyn_rc))))
};
let new_end = if let Some(parent_ctx) = parent_ctx {
if parent_ctx.repeater_index.is_some() {
// Repeaters run their user_init() code from RepeatedItemTree::init() after update() initialized model_data/index.
quote!(core::result::Result::Ok(self_rc))
} else {
quote! {
Self::user_init(sp::VRc::map(self_rc.clone(), |x| x));
core::result::Result::Ok(self_rc)
}
}
} else {
quote!(core::result::Result::Ok(self_rc))
};
let embedding_function = if parent_ctx.is_some() {
quote!(todo!("Components written in Rust can not get embedded yet."))
} else {
@ -1546,7 +1532,7 @@ fn generate_item_tree(
let globals = #globals;
sp::register_item_tree(&self_dyn_rc, globals.maybe_window_adapter_impl());
Self::init(sp::VRc::map(self_rc.clone(), |x| x), globals, 0, 1);
#new_end
core::result::Result::Ok(self_rc)
}
fn item_tree() -> &'static [sp::ItemTreeNode] {