diff options
author | 2023-01-05 16:40:45 +0100 | |
---|---|---|
committer | 2023-01-05 16:40:45 +0100 | |
commit | 31abc4ce0d8be384872c26fd1209382af6231c6c (patch) | |
tree | a4d8ff545c69f14dba06820f59c6ea1ab0bd313c /native/src/layout | |
parent | f641e20f7fb43932bb30776c607fe3745311ccd6 (diff) | |
download | iced-31abc4ce0d8be384872c26fd1209382af6231c6c.tar.gz iced-31abc4ce0d8be384872c26fd1209382af6231c6c.tar.bz2 iced-31abc4ce0d8be384872c26fd1209382af6231c6c.zip |
Fix `Layout::resolve` panicking under some circumstances
When `fill` has a bigger `Size` than `max`.
Diffstat (limited to 'native/src/layout')
-rw-r--r-- | native/src/layout/limits.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/native/src/layout/limits.rs b/native/src/layout/limits.rs index 33a452d0..0ddee91a 100644 --- a/native/src/layout/limits.rs +++ b/native/src/layout/limits.rs @@ -153,12 +153,17 @@ impl Limits { /// Computes the resulting [`Size`] that fits the [`Limits`] given the /// intrinsic size of some content. + #[allow(clippy::manual_clamp)] pub fn resolve(&self, intrinsic_size: Size) -> Size { Size::new( - intrinsic_size.width.clamp(self.fill.width, self.max.width), + intrinsic_size + .width + .min(self.max.width) + .max(self.fill.width), intrinsic_size .height - .clamp(self.fill.height, self.max.height), + .min(self.max.height) + .max(self.fill.height), ) } } |