Skip to content

Commit

Permalink
core: Do not panic when popups try to find their parent
Browse files Browse the repository at this point in the history
Popups may have normal `Item`s as parrent, while all the other
components always have a `DynamicTree` as a parent. So do not
panic when some component ends up with an `Item` as a parent.

Just return `None` instead of panicing.

We probably need to make the focus-handling more aware of
popups eventually, but this stops the panics.

Fixes: slint-ui#5826, slint-ui#5830
  • Loading branch information
hunger committed Aug 14, 2024
1 parent 0800919 commit 3b17f19
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion internal/core/item_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,8 @@ impl ItemRc {

let subtree_index = match parent_item_tree.get(parent_item_index)? {
crate::item_tree::ItemTreeNode::Item { .. } => {
panic!("Got an Item, expected a repeater!")
// Popups can trigger this case!
return None;
}
crate::item_tree::ItemTreeNode::DynamicTree { index, .. } => *index,
};
Expand Down

0 comments on commit 3b17f19

Please sign in to comment.