octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

h = gca; delete(h); h==gca -> ans=1


From: John W. Eaton
Subject: h = gca; delete(h); h==gca -> ans=1
Date: Wed, 22 Oct 2008 14:59:57 -0400

On 22-Oct-2008, Ben Abbott wrote:

| While this could be fixed in gca.m I'm sure it is better to take care of it 
at a lower level.
| 
| octave:102> plot(1:10)
| octave:103> gca
| ans = -21.032
| octave:104> delete(gca)
| octave:105> gca
| ans = -21.032

I think the following changeset fixes this problem.

Thanks,

jwe

# HG changeset patch
# User John W. Eaton <address@hidden>
# Date 1224701871 14400
# Node ID 81b124f463f93f0b7902b2dada3a7686d3b6d818
# Parent  1c213dff76fcd2575b202eda344090b544570fed
properly update currentaxes when axes are deleted

diff --git a/src/ChangeLog b/src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,4 +1,7 @@
 2008-10-22  John W. Eaton  <address@hidden>
+
+       * graphics.cc (figure::properties::remove_child): New function.
+       * graphics.h.in: Provide decl.
 
        * gl-render.cc (opengl_renderer::draw): Get all children.
 
diff --git a/src/graphics.cc b/src/graphics.cc
--- a/src/graphics.cc
+++ b/src/graphics.cc
@@ -2023,6 +2023,32 @@
     currentaxes = val;
   else
     gripe_set_invalid ("currentaxes");
+}
+
+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
diff --git a/src/graphics.h.in b/src/graphics.h.in
--- a/src/graphics.h.in
+++ b/src/graphics.h.in
@@ -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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]