Mercurial > hg > octave-lyh
diff scripts/plot/colorbar.m @ 14777:1230d5d58d2d
Fix segfault when replacing a colorbar axis. (Bug # 36576)
* scripts/plot/colorbar.m (resetaxis): Delete listener to axes "position"
property before reseting the position to its original state.
Simplify the code, and respect the original axes' units property.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Sun, 17 Jun 2012 19:17:26 -0400 |
parents | f3d52523cde1 |
children | 460a3c6d8bf1 |
line wrap: on
line diff
--- a/scripts/plot/colorbar.m +++ b/scripts/plot/colorbar.m @@ -162,7 +162,7 @@ "yliminclude", "off", "zliminclude", "off", "deletefcn", {@deletecolorbar, cax, obj}); - set (cax, "deletefcn", {@resetaxis, obj}); + set (cax, "deletefcn", {@resetaxis, ax, obj}); addlistener (ax, "clim", {@update_colorbar_clim, hi, vertical}); addlistener (ax, "plotboxaspectratio", {@update_colorbar_axis, cax, obj}); @@ -195,13 +195,15 @@ endif endfunction -function resetaxis (h, d, orig_props) - if (ishandle (h) && strcmp (get (h, "type"), "axes") - && (isempty (gcbf()) || strcmp (get (gcbf(), "beingdeleted"),"off")) - && ishandle (get (h, "axes"))) - set (get (h, "axes"), "position", orig_props.position, ... - "outerposition", orig_props.outerposition, ... - "activepositionproperty", orig_props.activepositionproperty); +function resetaxis (cax, d, ax, orig_props) + if (ishandle (ax) && strcmp (get (ax, "type"), "axes")) + dellistener (ax, "position") + units = get (ax, "units"); + set (ax, "units", orig_props.units) + set (ax, "position", orig_props.position, ... + "outerposition", orig_props.outerposition, ... + "activepositionproperty", orig_props.activepositionproperty); + set (ax, "units", units) endif endfunction