From e413e5e3e9b16515a6335f39c05d54ec71846817 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Thu, 7 Jan 2021 18:31:19 +0100 Subject: [PATCH] Fix precision issue in panel space allocation debug sanity check Closes https://github.com/emilk/egui/issues/99 --- CHANGELOG.md | 4 ++++ egui/src/context.rs | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b65dc563..7acd002b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * Add `ui.allocate_at_least` and `ui.allocate_exact_size`. +### Fixed 🐛 + +* Fixed a bug that would sometimes trigger a "Mismatching panels" panic in debug builds. + ## 0.7.0 - 2021-01-04 ### Added ⭐ diff --git a/egui/src/context.rs b/egui/src/context.rs index 837984bc..99861779 100644 --- a/egui/src/context.rs +++ b/egui/src/context.rs @@ -93,8 +93,8 @@ impl FrameState { /// Shrink `available_rect`. pub(crate) fn allocate_left_panel(&mut self, panel_rect: Rect) { debug_assert!( - panel_rect.min == self.available_rect.min, - "Mismatching panels. You must not create a panel from within another panel." + panel_rect.min.distance(self.available_rect.min) < 0.1, + "Mismatching left panel. You must not create a panel from within another panel." ); self.available_rect.min.x = panel_rect.max.x; self.unused_rect.min.x = panel_rect.max.x; @@ -104,8 +104,8 @@ impl FrameState { /// Shrink `available_rect`. pub(crate) fn allocate_top_panel(&mut self, panel_rect: Rect) { debug_assert!( - panel_rect.min == self.available_rect.min, - "Mismatching panels. You must not create a panel from within another panel." + panel_rect.min.distance(self.available_rect.min) < 0.1, + "Mismatching top panel. You must not create a panel from within another panel." ); self.available_rect.min.y = panel_rect.max.y; self.unused_rect.min.y = panel_rect.max.y;