fix(segmented_button): crash when enumerating context menu buttons
This commit is contained in:
parent
c53b43d41b
commit
96a82045d7
1 changed files with 9 additions and 7 deletions
|
|
@ -970,11 +970,12 @@ where
|
|||
|
||||
let Some((mut bounds, i)) = self
|
||||
.variant_bounds(state, layout.bounds())
|
||||
.enumerate()
|
||||
.find_map(|(i, item)| match item {
|
||||
ItemBounds::Button(e, bounds) if e == entity => Some((bounds, i)),
|
||||
.filter_map(|item| match item {
|
||||
ItemBounds::Button(entity, bounds) => Some((bounds, entity)),
|
||||
_ => None,
|
||||
})
|
||||
.enumerate()
|
||||
.find_map(|(i, (bounds, e))| if e == entity { Some((bounds, i)) } else { None })
|
||||
else {
|
||||
return;
|
||||
};
|
||||
|
|
@ -2529,11 +2530,12 @@ where
|
|||
|
||||
let (mut bounds, i) = self
|
||||
.variant_bounds(state, layout.bounds())
|
||||
.enumerate()
|
||||
.find_map(|(i, item)| match item {
|
||||
ItemBounds::Button(e, bounds) if e == entity => Some((bounds, i)),
|
||||
.filter_map(|item| match item {
|
||||
ItemBounds::Button(entity, bounds) => Some((bounds, entity)),
|
||||
_ => None,
|
||||
})?;
|
||||
})
|
||||
.enumerate()
|
||||
.find_map(|(i, (bounds, e))| if e == entity { Some((bounds, i)) } else { None })?;
|
||||
|
||||
assert!(
|
||||
self.context_menu
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue