Mercurial > hg > octave-nkf
diff libinterp/corefcn/graphics.cc @ 18673:5264b0ec9f97
Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
* graphics.cc (Fset): check if a property is read-only for 2 arguments call.
* graphics.cc (values_as_string, value_as_string, values_as_struct):
Don't return read-only properties.
author | pantxo <pantxo.diribarne@gmail.com> |
---|---|
date | Mon, 17 Mar 2014 22:38:36 +0100 |
parents | 3dac2a233386 |
children | cd83730e5e38 |
line wrap: on
line diff
--- a/libinterp/corefcn/graphics.cc +++ b/libinterp/corefcn/graphics.cc @@ -2984,10 +2984,12 @@ if (valid_object ()) { octave_map m = get ().map_value (); + graphics_object obj = gh_manager::get_object (get_handle ()); for (octave_map::const_iterator pa = m.begin (); pa != m.end (); pa++) { - if (pa->first != "children") + if (pa->first != "children" && + ! obj.has_readonly_property (pa->first)) { property p = get_properties ().get_property (pa->first); @@ -3016,7 +3018,9 @@ if (valid_object ()) { - if (prop != "children") + graphics_object obj = gh_manager::get_object (get_handle ()); + + if (prop != "children" && ! obj.has_readonly_property (prop)) { property p = get_properties ().get_property (prop); @@ -3044,11 +3048,13 @@ if (valid_object ()) { octave_scalar_map m = get ().scalar_map_value (); + graphics_object obj = gh_manager::get_object (get_handle ()); for (octave_scalar_map::const_iterator pa = m.begin (); pa != m.end (); pa++) { - if (pa->first != "children") + if (pa->first != "children" + && ! obj.has_readonly_property (pa->first)) { property p = get_properties ().get_property (pa->first); @@ -3068,6 +3074,25 @@ return retval; } +/* +%!test +%! hfig = figure ("visible", "off"); +%! unwind_protect +%! hax = axes (); +%! ret = set (hax, "tightinset"); +%! assert (isempty (ret)); +%! ret = set (hax, "type"); +%! assert (isempty (ret)); +%! ret = set (hfig, "__graphics_toolkit__"); +%! assert (isempty (ret)); +%! ret = set (0, "commandwindowsize"); +%! assert (isempty (ret)); +%! ret = set (0); +%! assert (! isfield (ret, "commandwindowsize")); +%! unwind_protect_cleanup +%! close (hfig); +%! end_unwind_protect +*/ graphics_object graphics_object::get_ancestor (const std::string& obj_type) const { @@ -8806,7 +8831,13 @@ octave_map pmap = obj.values_as_struct (); - if (pmap.isfield (property)) + if (obj.has_readonly_property (property)) + if (nargout != 0) + retval = Matrix (); + else + octave_stdout << "set: " << property + <<" is read-only" << std::endl; + else if (pmap.isfield (property)) { if (nargout != 0) retval = pmap.getfield (property)(0);