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
|
let Some((mut bounds, i)) = self
|
||||||
.variant_bounds(state, layout.bounds())
|
.variant_bounds(state, layout.bounds())
|
||||||
.enumerate()
|
.filter_map(|item| match item {
|
||||||
.find_map(|(i, item)| match item {
|
ItemBounds::Button(entity, bounds) => Some((bounds, entity)),
|
||||||
ItemBounds::Button(e, bounds) if e == entity => Some((bounds, i)),
|
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
|
.enumerate()
|
||||||
|
.find_map(|(i, (bounds, e))| if e == entity { Some((bounds, i)) } else { None })
|
||||||
else {
|
else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
@ -2529,11 +2530,12 @@ where
|
||||||
|
|
||||||
let (mut bounds, i) = self
|
let (mut bounds, i) = self
|
||||||
.variant_bounds(state, layout.bounds())
|
.variant_bounds(state, layout.bounds())
|
||||||
.enumerate()
|
.filter_map(|item| match item {
|
||||||
.find_map(|(i, item)| match item {
|
ItemBounds::Button(entity, bounds) => Some((bounds, entity)),
|
||||||
ItemBounds::Button(e, bounds) if e == entity => Some((bounds, i)),
|
|
||||||
_ => None,
|
_ => None,
|
||||||
})?;
|
})
|
||||||
|
.enumerate()
|
||||||
|
.find_map(|(i, (bounds, e))| if e == entity { Some((bounds, i)) } else { None })?;
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
self.context_menu
|
self.context_menu
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue