changeset 33340:fa8a486773fd stable

legend.m: Fix error if root property "showhiddenhandles" is "on" (bug #65442) * legend.m: At start of function, check root property "showhiddenhandles". If set to "on", then turn it "off". Create an onCleanup action to restore the setting at the end of the function.
author Rik <rik@octave.org>
date Fri, 05 Apr 2024 17:18:12 -0700
parents 35ac89ffcf7c
children 8e6e656b6f61 1d70b16c216b
files scripts/plot/appearance/legend.m
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/appearance/legend.m	Fri Apr 05 19:56:56 2024 +0200
+++ b/scripts/plot/appearance/legend.m	Fri Apr 05 17:18:12 2024 -0700
@@ -207,6 +207,12 @@
   ##        lock once that bug is properly fixed.
   mlock ();
 
+  ## legend() requires root property to be invisible.
+  if (strcmp (get (groot, 'showhiddenhandles'), 'on'))
+    cleanup = onCleanup (@() set (groot, 'showhiddenhandles', 'on'));
+    set (groot, 'showhiddenhandles', 'off');
+  endif
+
   opts = parse_opts (varargin{:});
 
   hl = opts.legend_handle;