Mercurial > octave
comparison libinterp/corefcn/graphics.in.h @ 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 | 67cad4e8f866 |
children | 9a0ce9eea1b7 e88a07dec498 |
comparison
equal
deleted
inserted
replaced
31239:dd6b37f67db2 | 31241:5ea5fe592a9a |
---|---|
1823 | 1823 |
1824 bool is_ok = true; | 1824 bool is_ok = true; |
1825 bool add_hidden = true; | 1825 bool add_hidden = true; |
1826 | 1826 |
1827 const Matrix visible_kids = do_get_children (false); | 1827 const Matrix visible_kids = do_get_children (false); |
1828 const Matrix hidden_kids = do_get_children (true); | |
1828 | 1829 |
1829 if (visible_kids.numel () == new_kids.numel ()) | 1830 if (visible_kids.numel () == new_kids.numel ()) |
1830 { | 1831 { |
1831 Matrix t1 = visible_kids.sort (); | 1832 Matrix t1 = visible_kids.sort (); |
1832 Matrix t2 = new_kids_column.sort (); | 1833 Matrix t2 = new_kids_column.sort (); |
1833 Matrix t3 = get_hidden ().sort (); | 1834 Matrix t3 = hidden_kids.sort (); |
1834 | 1835 |
1835 if (t1 != t2) | 1836 if (t1 != t2) |
1836 is_ok = false; | 1837 is_ok = false; |
1837 | 1838 |
1838 if (t1 == t3) | 1839 if (t1 == t3) |
1840 } | 1841 } |
1841 else | 1842 else |
1842 is_ok = false; | 1843 is_ok = false; |
1843 | 1844 |
1844 if (! is_ok) | 1845 if (! is_ok) |
1845 error ("set: new children must be a permutation of existing children"); | 1846 error ("set: new children list must be a permutation of existing " |
1846 | 1847 "children with visible handles"); |
1847 Matrix tmp = new_kids_column; | |
1848 | |
1849 if (add_hidden) | |
1850 tmp.stack (get_hidden ()); | |
1851 | 1848 |
1852 m_children_list.clear (); | 1849 m_children_list.clear (); |
1853 | 1850 |
1854 // Don't use do_init_children here, as that reverses the | 1851 // Don't use do_init_children here, as that reverses the |
1855 // order of the list, and we don't want to do that if setting | 1852 // order of the list, and we don't want to do that if setting |
1856 // the child list directly. | 1853 // the child list directly. |
1857 for (octave_idx_type i = 0; i < tmp.numel (); i++) | 1854 for (octave_idx_type i = 0; i < new_kids_column.numel (); i++) |
1858 m_children_list.push_back (tmp.xelem (i)); | 1855 m_children_list.push_back (new_kids_column.xelem (i)); |
1859 | 1856 |
1860 return is_ok; | 1857 if (add_hidden) |
1858 for (octave_idx_type i = 0; i < hidden_kids.numel (); i++) | |
1859 m_children_list.push_back (hidden_kids.xelem (i)); | |
1860 | |
1861 return true; | |
1861 } | 1862 } |
1862 | 1863 |
1863 private: | 1864 private: |
1864 void do_init_children (const Matrix& val) | 1865 void do_init_children (const Matrix& val) |
1865 { | 1866 { |