comparison 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
comparison
equal deleted inserted replaced
14776:0eb1b1eb2c76 14777:1230d5d58d2d
160 ctext = text (0, 0, "", "tag", "colorbar","visible", "off", 160 ctext = text (0, 0, "", "tag", "colorbar","visible", "off",
161 "handlevisibility", "off", "xliminclude", "off", 161 "handlevisibility", "off", "xliminclude", "off",
162 "yliminclude", "off", "zliminclude", "off", 162 "yliminclude", "off", "zliminclude", "off",
163 "deletefcn", {@deletecolorbar, cax, obj}); 163 "deletefcn", {@deletecolorbar, cax, obj});
164 164
165 set (cax, "deletefcn", {@resetaxis, obj}); 165 set (cax, "deletefcn", {@resetaxis, ax, obj});
166 166
167 addlistener (ax, "clim", {@update_colorbar_clim, hi, vertical}); 167 addlistener (ax, "clim", {@update_colorbar_clim, hi, vertical});
168 addlistener (ax, "plotboxaspectratio", {@update_colorbar_axis, cax, obj}); 168 addlistener (ax, "plotboxaspectratio", {@update_colorbar_axis, cax, obj});
169 addlistener (ax, "plotboxaspectratiomode", {@update_colorbar_axis, cax, obj}); 169 addlistener (ax, "plotboxaspectratiomode", {@update_colorbar_axis, cax, obj});
170 addlistener (ax, "dataaspectratio", {@update_colorbar_axis, cax, obj}); 170 addlistener (ax, "dataaspectratio", {@update_colorbar_axis, cax, obj});
193 "activepositionproperty", orig_props.activepositionproperty); 193 "activepositionproperty", orig_props.activepositionproperty);
194 endif 194 endif
195 endif 195 endif
196 endfunction 196 endfunction
197 197
198 function resetaxis (h, d, orig_props) 198 function resetaxis (cax, d, ax, orig_props)
199 if (ishandle (h) && strcmp (get (h, "type"), "axes") 199 if (ishandle (ax) && strcmp (get (ax, "type"), "axes"))
200 && (isempty (gcbf()) || strcmp (get (gcbf(), "beingdeleted"),"off")) 200 dellistener (ax, "position")
201 && ishandle (get (h, "axes"))) 201 units = get (ax, "units");
202 set (get (h, "axes"), "position", orig_props.position, ... 202 set (ax, "units", orig_props.units)
203 "outerposition", orig_props.outerposition, ... 203 set (ax, "position", orig_props.position, ...
204 "activepositionproperty", orig_props.activepositionproperty); 204 "outerposition", orig_props.outerposition, ...
205 "activepositionproperty", orig_props.activepositionproperty);
206 set (ax, "units", units)
205 endif 207 endif
206 endfunction 208 endfunction
207 209
208 function update_colorbar_clim (h, d, hi, vert) 210 function update_colorbar_clim (h, d, hi, vert)
209 if (ishandle (h) && strcmp (get (h, "type"), "image") 211 if (ishandle (h) && strcmp (get (h, "type"), "image")