Mercurial > octave
comparison scripts/plot/appearance/legend.m @ 21652:2e07dcdc6139
legend.m: Check handle is valid before delete (partial fix bug #47699).
* legend.m (deletelegend2): Check that invisible object t1 is valid
before trying to delete it. It may already have been deleted.
* legend.m (hideshowlegend): Use variable name hlegend, not ca,
for truth in advertising.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 28 Apr 2016 12:12:21 -0700 |
parents | ecce63c99c3f |
children | b571fc85953f |
comparison
equal
deleted
inserted
replaced
21651:b4354327d2b5 | 21652:2e07dcdc6139 |
---|---|
1146 end_unwind_protect | 1146 end_unwind_protect |
1147 endif | 1147 endif |
1148 endfor | 1148 endfor |
1149 endfunction | 1149 endfunction |
1150 | 1150 |
1151 function deletelegend1 (h, ~, ca) | 1151 function deletelegend1 (h, ~, hlegend) |
1152 if (isaxes (ca) | 1152 if (isaxes (hlegend) |
1153 && (isempty (gcbf ()) || strcmp (get (gcbf (), "beingdeleted"), "off")) | 1153 && (isempty (gcbf ()) || strcmp (get (gcbf (), "beingdeleted"), "off")) |
1154 && strcmp (get (ca, "beingdeleted"), "off")) | 1154 && strcmp (get (hlegend, "beingdeleted"), "off")) |
1155 delete (ca); | 1155 delete (hlegend); |
1156 endif | 1156 endif |
1157 endfunction | 1157 endfunction |
1158 | 1158 |
1159 function deletelegend2 (h, ~, ca, pos, outpos, t1, hplots) | 1159 function deletelegend2 (h, ~, ca, pos, outpos, t1, hplots) |
1160 for i = 1 : numel (ca) | 1160 for i = 1 : numel (ca) |
1170 set (ca(i), "units", units); | 1170 set (ca(i), "units", units); |
1171 end_unwind_protect | 1171 end_unwind_protect |
1172 endif | 1172 endif |
1173 endif | 1173 endif |
1174 endfor | 1174 endfor |
1175 set (t1, "deletefcn", ""); | 1175 if (ishandle (t1)) |
1176 delete (t1); | 1176 set (t1, "deletefcn", ""); |
1177 delete (t1); | |
1178 endif | |
1177 for i = 1 : numel (hplots) | 1179 for i = 1 : numel (hplots) |
1178 if (ishandle (hplots(i)) && strcmp (get (hplots(i), "type"), "line")) | 1180 if (ishandle (hplots(i)) && strcmp (get (hplots(i), "type"), "line")) |
1179 dellistener (hplots(i), "color"); | 1181 dellistener (hplots(i), "color"); |
1180 dellistener (hplots(i), "linestyle"); | 1182 dellistener (hplots(i), "linestyle"); |
1181 dellistener (hplots(i), "linewidth"); | 1183 dellistener (hplots(i), "linewidth"); |