# HG changeset patch # User Ben Abbott # Date 1339975046 14400 # Node ID 1230d5d58d2d1796be72d127f306449e4488b913 # Parent 0eb1b1eb2c7695d6fc5d31ab56bc294208d79182 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. diff --git a/scripts/plot/colorbar.m b/scripts/plot/colorbar.m --- 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