changeset 31241:5ea5fe592a9a

Don't delete labels when reordering of axes children (bug #63117) * graphics.in.h (children_property::do_set): Avoid using a temporary variable for new children list. Rephrase error message to be more accurate. Always return true for clarity.
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Tue, 27 Sep 2022 23:30:54 +0200
parents dd6b37f67db2
children 7018819318d1
files libinterp/corefcn/graphics.in.h
diffstat 1 files changed, 12 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/graphics.in.h	Sun Sep 25 06:22:25 2022 -0400
+++ b/libinterp/corefcn/graphics.in.h	Tue Sep 27 23:30:54 2022 +0200
@@ -1825,12 +1825,13 @@
     bool add_hidden = true;
 
     const Matrix visible_kids = do_get_children (false);
+    const Matrix hidden_kids = do_get_children (true);
 
     if (visible_kids.numel () == new_kids.numel ())
       {
         Matrix t1 = visible_kids.sort ();
         Matrix t2 = new_kids_column.sort ();
-        Matrix t3 = get_hidden ().sort ();
+        Matrix t3 = hidden_kids.sort ();
 
         if (t1 != t2)
           is_ok = false;
@@ -1842,22 +1843,22 @@
       is_ok = false;
 
     if (! is_ok)
-      error ("set: new children must be a permutation of existing children");
-
-    Matrix tmp = new_kids_column;
-
-    if (add_hidden)
-      tmp.stack (get_hidden ());
+      error ("set: new children list must be a permutation of existing "
+             "children with visible handles");
 
     m_children_list.clear ();
 
     // Don't use do_init_children here, as that reverses the
     // order of the list, and we don't want to do that if setting
     // the child list directly.
-    for (octave_idx_type i = 0; i < tmp.numel (); i++)
-      m_children_list.push_back (tmp.xelem (i));
-
-    return is_ok;
+    for (octave_idx_type i = 0; i < new_kids_column.numel (); i++)
+      m_children_list.push_back (new_kids_column.xelem (i));
+
+    if (add_hidden)
+      for (octave_idx_type i = 0; i < hidden_kids.numel (); i++)
+        m_children_list.push_back (hidden_kids.xelem (i));
+
+    return true;
   }
 
 private: