changeset 8266:81b124f463f9

properly update currentaxes when axes are deleted
author John W. Eaton <jwe@octave.org>
date Wed, 22 Oct 2008 14:57:51 -0400
parents 1c213dff76fc
children f2f1d07a7f0f
files src/ChangeLog src/graphics.cc src/graphics.h.in
diffstat 3 files changed, 31 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Wed Oct 22 14:04:27 2008 -0400
+++ b/src/ChangeLog	Wed Oct 22 14:57:51 2008 -0400
@@ -1,5 +1,8 @@
 2008-10-22  John W. Eaton  <jwe@octave.org>
 
+	* graphics.cc (figure::properties::remove_child): New function.
+	* graphics.h.in: Provide decl.
+
 	* gl-render.cc (opengl_renderer::draw): Get all children.
 
 	* DLD-FUNCTIONS/fltk_backend.cc (__fltk_redraw__):
--- a/src/graphics.cc	Wed Oct 22 14:04:27 2008 -0400
+++ b/src/graphics.cc	Wed Oct 22 14:57:51 2008 -0400
@@ -2026,6 +2026,32 @@
 }
 
 void
+figure::properties::remove_child (const graphics_handle& gh)
+{
+  base_properties::remove_child (gh);
+
+  if (gh == currentaxes.handle_value ())
+    {
+      graphics_handle new_currentaxes;
+
+      for (octave_idx_type i = 0; i < children.numel (); i++)
+	{
+	  graphics_handle kid = children(i);
+
+	  graphics_object go = gh_manager::get_object (kid);
+
+	  if (go.isa ("axes"))
+	    {
+	      new_currentaxes = kid;
+	      break;
+	    }
+	}
+
+      currentaxes = new_currentaxes;
+    }
+}
+
+void
 figure::properties::set_visible (const octave_value& val)
 {
   std::string s = val.string_value ();
--- a/src/graphics.h.in	Wed Oct 22 14:04:27 2008 -0400
+++ b/src/graphics.h.in	Wed Oct 22 14:57:51 2008 -0400
@@ -2218,6 +2218,8 @@
   class OCTINTERP_API properties : public base_properties
   {
   public:
+    void remove_child (const graphics_handle& h);
+
     void set_visible (const octave_value& val);
 
     graphics_backend get_backend (void) const