From 0490b303831869c12c84d61025aab1bf2d1f1414 Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Sun, 19 Oct 2008 20:15:32 +0000 Subject: Fixed adding an idle handler during a draw() call (STR #1950) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6473 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- CHANGES | 2 ++ src/Fl.cxx | 4 ++++ test/mandelbrot.cxx | 6 +++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index 6bb479303..4baadbfd4 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,7 @@ CHANGES IN FLTK 1.3.0 + - Fixed adding an idle handler during + a draw() call (STR #1950) - Fl_Group::clip_children() is now public (STR #2017) - Added clarification to Fl_GL_Window mode function (STR #1945) diff --git a/src/Fl.cxx b/src/Fl.cxx index 57d8cf778..0b62f4c4e 100644 --- a/src/Fl.cxx +++ b/src/Fl.cxx @@ -381,6 +381,8 @@ double Fl::wait(double time_to_wait) { if (idle) time_to_wait = 0.0; } flush(); + if (idle && !in_idle) // 'idle' may have been set within flush() + time_to_wait = 0.0; return fl_wait(time_to_wait); #else @@ -427,6 +429,8 @@ double Fl::wait(double time_to_wait) { } else { // do flush first so that user sees the display: flush(); + if (idle && !in_idle) // 'idle' may have been set within flush() + time_to_wait = 0.0; return fl_wait(time_to_wait); } #endif diff --git a/test/mandelbrot.cxx b/test/mandelbrot.cxx index 1bc6293a0..358d91b6a 100644 --- a/test/mandelbrot.cxx +++ b/test/mandelbrot.cxx @@ -33,12 +33,12 @@ Drawing_Window mbrot; Drawing_Window jbrot; -void idle() { - if (!mbrot.d->idle() && !(jbrot.d && jbrot.d->idle())) Fl::set_idle(0); +void idle(void*) { + if (!mbrot.d->idle() && !(jbrot.d && jbrot.d->idle())) Fl::remove_idle(idle); } void set_idle() { - Fl::set_idle(idle); + Fl::add_idle(idle); } static void window_callback(Fl_Widget*, void*) {exit(0);} -- cgit v1.2.3