From ff10602c65eee43bb083c9d5c8e458f3e3057f33 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 17 Nov 2004 19:37:45 +0000 Subject: [PATCH] Make sure that timer delay values are positive-definite, otherwise user code that wants to use zero delay to mean "next frame" will get stuck in an infinite loop. --- simgear/structure/event_mgr.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/simgear/structure/event_mgr.cxx b/simgear/structure/event_mgr.cxx index 1ada33c8..c66f00ce 100644 --- a/simgear/structure/event_mgr.cxx +++ b/simgear/structure/event_mgr.cxx @@ -4,6 +4,10 @@ void SGEventMgr::add(SGCallback* cb, double interval, double delay, bool repeat, bool simtime) { + // Clamp the delay value to 1 usec, so that user code can use + // "zero" as a synonym for "next frame". + if(delay <= 0) delay = 0.000001; + SGTimer* t = new SGTimer; t->interval = interval; t->callback = cb; -- 2.39.5