changeset 13935:e48e8253ce58

Re-allow recursive graphics event processing. * src/graphics.cc (gh_manager::do_process_events): Re-allow recursivity.
author Michael Goffioul <michael.goffioul@gmail.com>
date Fri, 25 Nov 2011 17:09:19 +0000
parents 7a756a7e145b
children bfaacd5e7379
files src/graphics.cc
diffstat 1 files changed, 44 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- a/src/graphics.cc	Fri Nov 25 11:29:31 2011 -0500
+++ b/src/graphics.cc	Fri Nov 25 17:09:19 2011 +0000
@@ -7792,63 +7792,60 @@
 {
   graphics_event e;
   bool old_Vdrawnow_requested = Vdrawnow_requested;
-  unwind_protect frame;
-
-  static int process_events_executing = 0;
-
-  frame.protect_var (process_events_executing);
-
-  if (++process_events_executing <= 1)
-    {
-      do
-        {
-          e = graphics_event ();
-
-          gh_manager::lock ();
-
-          if (! event_queue.empty ())
+  bool events_executed = false;
+
+  do
+    {
+      e = graphics_event ();
+
+      gh_manager::lock ();
+
+      if (! event_queue.empty ())
+        {
+          if (callback_objects.empty () || force)
             {
-              if (callback_objects.empty () || force)
+              e = event_queue.front ();
+
+              event_queue.pop_front ();
+            }
+          else
+            {
+              const graphics_object& go = callback_objects.front ();
+
+              if (go.get_properties ().is_interruptible ())
                 {
                   e = event_queue.front ();
 
                   event_queue.pop_front ();
                 }
-              else
-                {
-                  const graphics_object& go = callback_objects.front ();
-
-                  if (go.get_properties ().is_interruptible ())
-                    {
-                      e = event_queue.front ();
-
-                      event_queue.pop_front ();
-                    }
-                }
             }
-
-          gh_manager::unlock ();
-
-          if (e.ok ())
-            e.execute ();
-        }
-      while (e.ok ());
-
-      gh_manager::lock ();
-
-      if (event_queue.empty () && event_processing == 0)
-        command_editor::remove_event_hook (gh_manager::process_events);
+        }
 
       gh_manager::unlock ();
 
-      flush_octave_stdout ();
-
-      if (Vdrawnow_requested && ! old_Vdrawnow_requested)
-        {
-          feval ("drawnow");
-
-          Vdrawnow_requested = false;
-        }
+      if (e.ok ())
+        {
+          e.execute ();
+          events_executed = true;
+        }
+    }
+  while (e.ok ());
+
+  gh_manager::lock ();
+
+  if (event_queue.empty () && event_processing == 0)
+    command_editor::remove_event_hook (gh_manager::process_events);
+
+  gh_manager::unlock ();
+
+  if (events_executed)
+    flush_octave_stdout ();
+
+  if (Vdrawnow_requested && ! old_Vdrawnow_requested)
+    {
+      feval ("drawnow");
+
+      Vdrawnow_requested = false;
     }
 
   return 0;