From 3c029a45aca5257fc59640b1df8015f5893de559 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Wed, 27 Mar 2024 16:14:22 +0100 Subject: [PATCH] Fix `Context::repaint_causes` returning no causes (#4248) It would return the causes for repainting again collected this frame, instead of the cause for repainting the current frame. * Part of https://github.com/emilk/egui/issues/3931 --- crates/egui/src/context.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index 258c39bf..376c41d9 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -252,7 +252,7 @@ struct ViewportState { } /// What called [`Context::request_repaint`]? -#[derive(Clone, Debug)] +#[derive(Clone)] pub struct RepaintCause { /// What file had the call that requested the repaint? pub file: &'static str, @@ -261,6 +261,12 @@ pub struct RepaintCause { pub line: u32, } +impl std::fmt::Debug for RepaintCause { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}:{}", self.file, self.line) + } +} + impl RepaintCause { /// Capture the file and line number of the call site. #[allow(clippy::new_without_default)] @@ -1465,7 +1471,7 @@ impl Context { self.read(|ctx| { ctx.viewports .get(&ctx.viewport_id()) - .map(|v| v.repaint.causes.clone()) + .map(|v| v.repaint.prev_causes.clone()) }) .unwrap_or_default() }