From b0eb684d315b497d8f93703358a477630e2179b8 Mon Sep 17 00:00:00 2001 From: CapsizeGlimmer <> Date: Tue, 5 Oct 2021 20:12:09 +0000 Subject: [PATCH] Prevent "Error setting/centering cursor position" message spam --- voxygen/src/window.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/voxygen/src/window.rs b/voxygen/src/window.rs index 0deb749344..eacc4319be 100644 --- a/voxygen/src/window.rs +++ b/voxygen/src/window.rs @@ -969,7 +969,11 @@ impl Window { d.y as f64 + self.cursor_position.y, )) { - error!("Error setting cursor position: {:?}", err); + // Log this error once rather than every frame + static SPAM_GUARD: std::sync::Once = std::sync::Once::new(); + SPAM_GUARD.call_once(|| { + error!("Error setting cursor position: {:?}", err); + }) } } } @@ -994,7 +998,11 @@ impl Window { dimensions[1] / (2_f64), )) { - error!("Error centering cursor position: {:?}", err); + // Log this error once rather than every frame + static SPAM_GUARD: std::sync::Once = std::sync::Once::new(); + SPAM_GUARD.call_once(|| { + error!("Error centering cursor position: {:?}", err); + }) } }