changeset 25992:2d739bbe744b

openfig.m: Only return graphics handle output if requested. * openfig.m: Use new variable 'htmp' as handle for all operations. If nargout > 0 then assign output 'h' the value of 'htmp'.
author Rik <rik@octave.org>
date Wed, 31 Oct 2018 14:29:03 -0700
parents 57952dd2da42
children f75bb9d659e0
files scripts/plot/util/openfig.m
diffstat 1 files changed, 14 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/util/openfig.m	Wed Oct 31 12:57:16 2018 -0700
+++ b/scripts/plot/util/openfig.m	Wed Oct 31 14:29:03 2018 -0700
@@ -94,21 +94,28 @@
 
   ## Reuse an existing figure?
   if (! copies)
-    h = findobj (allchild (0), "type", "figure", "FileName", filename);
-    if (! isempty (h))
-      h = h(end);
+    htmp = findobj (allchild (0), "type", "figure", "FileName", filename);
+    if (! isempty (htmp))
+      htmp = htmp(end);
       if (! isempty (visibility))
-        set (h, visibility{:});
+        set (htmp, visibility{:});
       endif
-      movegui (h, "onscreen");
+      movegui (htmp, "onscreen");
+      if (nargout > 0)
+        h = htmp;
+      endif
       return;
     endif
   endif
 
   ## Load graphics objects from file
   prop_struct = cell2struct (visibility(2:2:end), visibility(1:2:end), 2);
-  h = hgload (filename, prop_struct);
-  set (h, "FileName", filename);
+  htmp = hgload (filename, prop_struct);
+  set (htmp, "FileName", filename);
+
+  if (nargout > 0)
+    h = htmp;
+  endif
 
 endfunction