Mercurial > octave-nkf
comparison libinterp/corefcn/graphics.cc @ 18449:0cbd0d285541
Avoid reseting "parent" property to the same value (bug #37752).
* base_properties::set_parent (graphics.cc): do nothing if current and new parent are the same
* add test according to bug #37752
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Wed, 12 Feb 2014 21:40:19 +0100 |
parents | ec9b35e60f95 |
children | c579bd4e12c9 |
comparison
equal
deleted
inserted
replaced
18448:b26d6be1767a | 18449:0cbd0d285541 |
---|---|
2775 if (new_parent.ok ()) | 2775 if (new_parent.ok ()) |
2776 { | 2776 { |
2777 // Remove child from current parent | 2777 // Remove child from current parent |
2778 graphics_object old_parent_obj; | 2778 graphics_object old_parent_obj; |
2779 old_parent_obj = gh_manager::get_object (get_parent ()); | 2779 old_parent_obj = gh_manager::get_object (get_parent ()); |
2780 old_parent_obj.remove_child (__myhandle__); | 2780 |
2781 | |
2782 if (old_parent_obj.get_handle () != hnp) | |
2783 old_parent_obj.remove_child (__myhandle__); | |
2784 else | |
2785 // Do nothing more | |
2786 return; | |
2781 | 2787 |
2782 // Check new parent's parent is not this child to avoid recursion | 2788 // Check new parent's parent is not this child to avoid recursion |
2783 graphics_object new_parent_obj; | 2789 graphics_object new_parent_obj; |
2784 new_parent_obj = gh_manager::get_object (new_parent); | 2790 new_parent_obj = gh_manager::get_object (new_parent); |
2785 if (new_parent_obj.get_parent () == __myhandle__) | 2791 if (new_parent_obj.get_parent () == __myhandle__) |
2797 } | 2803 } |
2798 } | 2804 } |
2799 else | 2805 else |
2800 error ("set: expecting parent to be a graphics handle"); | 2806 error ("set: expecting parent to be a graphics handle"); |
2801 } | 2807 } |
2808 | |
2809 /* | |
2810 %!test | |
2811 %! hf = figure ("visible", "off"); | |
2812 %! unwind_protect | |
2813 %! hax = gca (); | |
2814 %! set (hax, "parent", gcf ()) | |
2815 %! assert (gca (), hax) | |
2816 %! unwind_protect_cleanup | |
2817 %! close (hf); | |
2818 %! end_unwind_protect | |
2819 */ | |
2802 | 2820 |
2803 void | 2821 void |
2804 base_properties::mark_modified (void) | 2822 base_properties::mark_modified (void) |
2805 { | 2823 { |
2806 __modified__ = "on"; | 2824 __modified__ = "on"; |