diff scripts/plot/appearance/legend.m @ 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 2e484f9f1f18
children 54d87fbbb421
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;