Mercurial > octave
changeset 24420:e1390a99a993
close.m: update cset 9213b8166af9 for better Matlab compatibility (bug #52621).
* close.m: Close hidden figures without "hidden" argument if they are
identified specifically either by handle or name. Don't change
HandleVisibility of figures that are about to be deleted as it is
unnecessary.
author | Rik <rik@octave.org> |
---|---|
date | Sat, 16 Dec 2017 08:22:36 -0800 |
parents | c23b9af6a664 |
children | fc6354114864 |
files | scripts/plot/util/close.m |
diffstat | 1 files changed, 7 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/util/close.m Fri Dec 15 12:51:20 2017 -0800 +++ b/scripts/plot/util/close.m Sat Dec 16 08:22:36 2017 -0800 @@ -18,12 +18,8 @@ ## -*- texinfo -*- ## @deftypefn {} {} close -## @deftypefnx {} {} close @var{h} +## @deftypefnx {} {} close (@var{h}) ## @deftypefnx {} {} close @var{figname} -## @deftypefnx {} {} close (@var{h}) -## @deftypefnx {} {} close (@var{figname}) -## @deftypefnx {} {} close (@dots{}, "hidden") -## @deftypefnx {} {} close (@dots{}, "force") ## @deftypefnx {} {} close all ## @deftypefnx {} {} close all hidden ## @deftypefnx {} {} close all force @@ -38,11 +34,12 @@ ## If the argument @qcode{"all"} is given then all figures with visible handles ## (HandleVisibility = @qcode{"on"}) are closed. ## -## If the argument @qcode{"hidden"} is given then figures, including hidden -## ones, are closed. +## If the additional argument @qcode{"hidden"} is given then all figures, +## including hidden ones, are closed. ## -## If the argument @qcode{"force"} is given then figures are closed even when -## @qcode{"closerequestfcn"} has been altered to prevent closing the window. +## If the additional argument @qcode{"force"} is given then figures are closed +## even when @qcode{"closerequestfcn"} has been altered to prevent closing the +## window. ## ## Implementation Note: @code{close} operates by making the handle @var{h} the ## current figure, and then calling the function specified by the @@ -74,11 +71,10 @@ figs = get (0, "children"); figs = figs(isfigure (figs)); else - figs = findobj ("-depth", 1, "name", arg1, "type", "figure"); + figs = findall ("-depth", 1, "name", arg1, "type", "figure"); endif elseif (any (isfigure (arg1))) figs = arg1(isfigure (arg1)); - figs = figs(strcmp ("on", get (figs, "handlevisibility"))); elseif (isempty (arg1)) figs = []; # Silently accept null argument for Matlab compatibility else @@ -104,8 +100,6 @@ delete (figs); return; endif - ## Unhide hidden figures that are about to be deleted - set (figs, "handlevisibility", "on"); else error ('close: second argument must be "hidden" or "force"'); endif @@ -166,26 +160,6 @@ %! end_unwind_protect %!test -%! ## Test closing hidden figures -%! hf1 = figure ("visible", "off", "handlevisibility", "off"); -%! hf2 = figure ("visible", "off"); -%! unwind_protect -%! close (hf1); -%! assert (isfigure (hf1)); # figure not deleted -%! close ([hf1 hf2]); -%! assert (isfigure (hf1) && ! isfigure (hf2)); -%! close (hf1, "hidden"); -%! assert (! isfigure (hf1)); # figure finally deleted -%! unwind_protect_cleanup -%! if (isfigure (hf1)) -%! delete (hf1); -%! endif -%! if (isfigure (hf2)) -%! delete (hf2); -%! endif -%! end_unwind_protect - -%!test %! ## Test forcing the close of a figure %! hf = figure ("visible", "off", "closerequestfcn", []); %! unwind_protect