changeset 13324:1e12601d2697

make handles with their handlevisibility property set to "callback" visible in callback functions * graphics.cc (executing_callback): New file scope variable. (callback_property::execute): Protect executing_callback and set it to true when executing callback function. * graphics.cc (base_properties::is_handle_visible): Move here from graphics.h.in. Check executing_callback to decide whether handles that have their handlevisibility property set to "callback" should be visible.
author John W. Eaton <jwe@octave.org>
date Tue, 11 Oct 2011 22:02:39 -0400
parents de081abd32c6
children 09b157ab2672
files src/graphics.cc src/graphics.h.in
diffstat 2 files changed, 18 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/graphics.cc	Tue Oct 11 21:55:21 2011 -0400
+++ b/src/graphics.cc	Tue Oct 11 22:02:39 2011 -0400
@@ -1387,6 +1387,11 @@
   return false;
 }
 
+// If TRUE, we are executing any callback function, or the functions it
+// calls.  Used to determine handle visibility inside callback
+// functions.
+static bool executing_callback = false;
+
 void
 callback_property::execute (const octave_value& data) const
 {
@@ -1397,9 +1402,14 @@
   // callback routines.
   frame.protect_var (executing);
 
+  // We are executing a callback function, so allow handles that have
+  // their handlevisibility property set to "callback" to be visible.
+  frame.protect_var (executing_callback);
+
   if (! executing)
     {
       executing = true;
+      executing_callback = true;
 
       if (callback.is_defined () && ! callback.is_empty ())
         gh_manager::execute_callback (get_parent (), callback, data);
@@ -2448,6 +2458,13 @@
     obj.update_axis_limits (axis_type, h);
 }
 
+bool
+base_properties::is_handle_visible (void) const
+{
+  return (handlevisibility.is ("on")
+          || executing_callback && ! handlevisibility.is ("off"));
+}
+
 graphics_toolkit
 base_properties::get_toolkit (void) const
 {
--- a/src/graphics.h.in	Tue Oct 11 21:55:21 2011 -0400
+++ b/src/graphics.h.in	Tue Oct 11 22:02:39 2011 -0400
@@ -2382,10 +2382,7 @@
   virtual bool is_climinclude (void) const { return false; }
   virtual bool is_aliminclude (void) const { return false; }
 
-  bool is_handle_visible (void) const
-  {
-    return ! handlevisibility.is ("off");
-  }
+  bool is_handle_visible (void) const;
 
   std::set<std::string> dynamic_property_names (void) const;