changeset 29920:12d77b69df12

figure: correctly detect "visible" option for existing figure (bug #60969) * figure.m: Fix detection of "visible", "off" option pair.
author John W. Eaton <jwe@octave.org>
date Mon, 26 Jul 2021 11:20:14 -0400
parents 4559cdcc4562
children 6b7ac07ffa85
files scripts/plot/util/figure.m
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/util/figure.m	Sun Jul 25 16:28:44 2021 +0200
+++ b/scripts/plot/util/figure.m	Mon Jul 26 11:20:14 2021 -0400
@@ -106,9 +106,17 @@
 
   ## When switching to figure N, make figure visible and on top of stack,
   ## unless visibility is explicitly switched off.
-  if (! init_new_figure && ! any (strcmpi (varargin(1:2:end), "visible")
-                                  && strcmpi (varargin(2:2:end), "off")))
-    set (f, "visible", "on");
+  if (! init_new_figure)
+    vis_on = true;
+    idx = find (strcmpi (varargin(1:2:end), "visible"), 1) * 2 - 1;
+    if (! isempty (idx))
+      if (idx < numel (varargin) && strcmpi (varargin{idx+1}, "off"))
+        vis_on = false;
+      endif
+    endif
+    if (vis_on)
+      set (f, "visible", "on");
+    endif
     __show_figure__ (f);
   endif