fix(wayland): properly destroy panel items

This commit is contained in:
Nova
2022-09-02 08:36:02 -04:00
parent a43b30da41
commit d92cbf01d1
5 changed files with 81 additions and 39 deletions

View File

@@ -92,7 +92,7 @@ pub struct Item {
pub specialization: ItemType,
}
impl Item {
pub fn new(
pub fn add_to(
node: &Arc<Node>,
type_info: &'static TypeInfo,
specialization: ItemType,
@@ -109,6 +109,7 @@ impl Item {
if let Some(ui) = type_info.ui.lock().upgrade() {
ui.handle_create_item(&item);
}
let _ = node.item.set(item.clone());
item
}
fn make_alias(&self, client: &Arc<Client>, parent: &str) -> (Arc<Node>, Arc<Alias>) {
@@ -173,9 +174,11 @@ pub struct EnvironmentItem {
}
impl EnvironmentItem {
pub fn add_to(node: &Arc<Node>, path: String) {
let specialization = ItemType::Environment(EnvironmentItem { path });
let item = Item::new(node, &ITEM_TYPE_INFO_ENVIRONMENT, specialization);
let _ = node.item.set(item);
Item::add_to(
node,
&ITEM_TYPE_INFO_ENVIRONMENT,
ItemType::Environment(EnvironmentItem { path }),
);
node.add_local_method("getPath", EnvironmentItem::get_path_flex);
}