use checked_sub to fix panic on window resize.
bug link: https://github.com/iced-rs/iced/issues/1773
This commit is contained in:
parent
3b6373d0f4
commit
e790e8e718
1 changed files with 10 additions and 8 deletions
|
|
@ -243,14 +243,16 @@ impl<'b> Iterator for LayoutRunIter<'b> {
|
|||
return None;
|
||||
}
|
||||
|
||||
self.remaining_len -= 1;
|
||||
return Some(LayoutRun {
|
||||
line_i: self.line_i,
|
||||
text: line.text(),
|
||||
rtl: shape.rtl,
|
||||
glyphs: &layout_line.glyphs,
|
||||
line_y: self.line_y,
|
||||
line_w: layout_line.w,
|
||||
return self.remaining_len.checked_sub(1).map(|num| {
|
||||
self.remaining_len = num;
|
||||
LayoutRun {
|
||||
line_i: self.line_i,
|
||||
text: line.text(),
|
||||
rtl: shape.rtl,
|
||||
glyphs: &layout_line.glyphs,
|
||||
line_y: self.line_y,
|
||||
line_w: layout_line.w,
|
||||
}
|
||||
});
|
||||
}
|
||||
self.line_i += 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue