diff src/graphics.cc @ 13323:de081abd32c6

don't execute graphics handle callback functions recursively * graphics.h.in (callback_property::executing): New data member. (callback_property::callback_property): Initialize it. graphics.cc (callback_property::execute): Protect executing member variable. Avoid executing callback if we are already doing so.
author John W. Eaton <jwe@octave.org>
date Tue, 11 Oct 2011 21:55:21 -0400
parents 834f904a3dcb
children 1e12601d2697
line wrap: on
line diff
--- a/src/graphics.cc	Tue Oct 11 18:08:44 2011 -0400
+++ b/src/graphics.cc	Tue Oct 11 21:55:21 2011 -0400
@@ -1390,8 +1390,20 @@
 void
 callback_property::execute (const octave_value& data) const
 {
-  if (callback.is_defined () && ! callback.is_empty ())
-    gh_manager::execute_callback (get_parent (), callback, data);
+  unwind_protect frame;
+
+  // We are executing the callback function associated with this
+  // callback property.  When set to true, we avoid recursive calls to
+  // callback routines.
+  frame.protect_var (executing);
+
+  if (! executing)
+    {
+      executing = true;
+
+      if (callback.is_defined () && ! callback.is_empty ())
+        gh_manager::execute_callback (get_parent (), callback, data);
+    }
 }
 
 // Used to cache dummy graphics objects from which dynamic