changeset 23271:cc9dcadcef6b

Only return a handle from ui* functions if nargout > 0 (bug #49751). * uicontrol.m, uipanel.m, uipushtool.m, uiresume.m, uitoggletool.m, uitoolbar.m: Capture handle of newly created object in htmp and assign to output only if nargout > 0. Update docstrings to show calling convention.
author Rik <rik@octave.org>
date Sun, 12 Mar 2017 22:06:01 -0700
parents 79122fab82ee
children 3983ac6f5920
files scripts/gui/uicontrol.m scripts/gui/uipanel.m scripts/gui/uipushtool.m scripts/gui/uiresume.m scripts/gui/uitoggletool.m scripts/gui/uitoolbar.m
diffstat 6 files changed, 61 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/gui/uicontrol.m	Sun Mar 12 19:12:27 2017 -0700
+++ b/scripts/gui/uicontrol.m	Sun Mar 12 22:06:01 2017 -0700
@@ -107,6 +107,10 @@
 
   [h, args] = __uiobject_split_args__ ("uicontrol", varargin,
                                        {"figure", "uipanel", "uibuttongroup"});
-  hui = __go_uicontrol__ (h, args{:});
+  htmp = __go_uicontrol__ (h, args{:});
 
+  if (nargout > 0)
+    hui = htmp;
+  endif
+  
 endfunction
--- a/scripts/gui/uipanel.m	Sun Mar 12 19:12:27 2017 -0700
+++ b/scripts/gui/uipanel.m	Sun Mar 12 22:06:01 2017 -0700
@@ -17,10 +17,11 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn  {} {@var{hui} =} uipanel (@var{property}, @var{value}, @dots{})
-## @deftypefnx {} {@var{hui} =} uipanel (@var{parent}, "@var{property}, @var{value}, @dots{})
+## @deftypefn  {} {} uipanel (@var{property}, @var{value}, @dots{})
+## @deftypefnx {} {} uipanel (@var{parent}, "@var{property}, @var{value}, @dots{})
+## @deftypefnx {} {@var{hui} =} uipanel (@dots{})
 ##
-## Create a uipanel object and return a handle to it.
+## Create a uipanel object.
 ##
 ## uipanels are used as containers to group other uicontrol objects.
 ##
@@ -34,6 +35,9 @@
 ##
 ## Uipanel properties are documented at @ref{Uipanel Properties}.
 ##
+## The optional return value @var{hui} is a graphics handle to the created
+## uipanel object.
+##
 ## Examples:
 ##
 ## @example
@@ -57,6 +61,10 @@
 
   [h, args] = __uiobject_split_args__ ("uipanel", varargin,
                                        {"figure", "uipanel", "uibuttongroup"});
-  hui = __go_uipanel__ (h, args{:});
+  htmp = __go_uipanel__ (h, args{:});
+  
+  if (nargout > 0)
+    hui = htmp;
+  endif
 
 endfunction
--- a/scripts/gui/uipushtool.m	Sun Mar 12 19:12:27 2017 -0700
+++ b/scripts/gui/uipushtool.m	Sun Mar 12 22:06:01 2017 -0700
@@ -17,10 +17,11 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn  {} {@var{hui} =} uipushtool (@var{property}, @var{value}, @dots{})
-## @deftypefnx {} {@var{hui} =} uipushtool (@var{parent}, @var{property}, @var{value}, @dots{})
+## @deftypefn  {} {} uipushtool (@var{property}, @var{value}, @dots{})
+## @deftypefnx {} {} uipushtool (@var{parent}, @var{property}, @var{value}, @dots{})
+## @deftypefnx {} {@var{hui} =} uipushtool (@dots{})
 ##
-## Create a uipushtool object and return a handle to it.
+## Create a uipushtool object.
 ##
 ## uipushtools are buttons that appear on a figure toolbar.  The button is
 ## created with a border that is shown when the user hovers over the button.
@@ -39,6 +40,9 @@
 ##
 ## Uipushtool properties are documented at @ref{Uipushtool Properties}.
 ##
+## The optional return value @var{hui} is a graphics handle to the created
+## uipushobject object.
+##
 ## Examples:
 ##
 ## @example
@@ -70,6 +74,11 @@
       h = h(1);
     endif
   endif
-  hui = __go_uipushtool__ (h, args{:});
+  
+  htmp = __go_uipushtool__ (h, args{:});
+  
+  if (nargout > 0)
+    hui = htmp;
+  endif
 
 endfunction
--- a/scripts/gui/uiresume.m	Sun Mar 12 19:12:27 2017 -0700
+++ b/scripts/gui/uiresume.m	Sun Mar 12 22:06:01 2017 -0700
@@ -30,6 +30,10 @@
 
 function uiresume (h)
 
+  if (nargin < 1)
+    h = gcf ();
+  endif
+
   if (! isfigure (h))
     error ("uiresume: invalid figure handle H");
   endif
--- a/scripts/gui/uitoggletool.m	Sun Mar 12 19:12:27 2017 -0700
+++ b/scripts/gui/uitoggletool.m	Sun Mar 12 22:06:01 2017 -0700
@@ -17,10 +17,11 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn  {} {@var{hui} =} uitoggletool (@var{property}, @var{value}, @dots{})
-## @deftypefnx {} {@var{hui} =} uitoggletool (@var{parent}, @var{property}, @var{value}, @dots{})
+## @deftypefn  {} {} uitoggletool (@var{property}, @var{value}, @dots{})
+## @deftypefnx {} {} uitoggletool (@var{parent}, @var{property}, @var{value}, @dots{})
+## @deftypefnx {} {@var{hui} =} uitoggletool (@dots{})
 ##
-## Create a uitoggletool object and return a handle to it.
+## Create a uitoggletool object.
 ##
 ## uitoggletool are togglebuttons that appear on a figure toolbar.  The
 ## button is created with a border that is shown when the user hovers over
@@ -39,6 +40,9 @@
 ##
 ## Uitoggletool properties are documented at @ref{Uitoggletool Properties}.
 ##
+## The optional return value @var{hui} is a graphics handle to the created
+## uitoggletool object.
+##
 ## Examples:
 ##
 ## @example
@@ -70,6 +74,11 @@
       h = h(1);
     endif
   endif
-  hui = __go_uitoggletool__ (h, args{:});
+  
+  htmp = __go_uitoggletool__ (h, args{:});
+  
+  if (nargout > 0)
+    hui = htmp;
+  endif
 
 endfunction
--- a/scripts/gui/uitoolbar.m	Sun Mar 12 19:12:27 2017 -0700
+++ b/scripts/gui/uitoolbar.m	Sun Mar 12 22:06:01 2017 -0700
@@ -17,11 +17,12 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn  {} {@var{hui} =} uitoolbar (@var{property}, @var{value}, @dots{})
-## @deftypefnx {} {@var{hui} =} uitoolbar (@var{parent}, @var{property}, @var{value}, @dots{})
+## @deftypefn  {} {} uitoolbar (@var{property}, @var{value}, @dots{})
+## @deftypefnx {} {} uitoolbar (@var{parent}, @var{property}, @var{value}, @dots{})
+## @deftypefnx {} {@var{hui} =} uitoolbar (@dots{})
 ##
-## Create a uitoolbar object and return a handle to it.  A uitoolbar displays
-## uitoggletool and uipushtool buttons.
+## Create a uitoolbar object.  A uitoolbar displays uitoggletool and uipushtool
+## buttons.
 ##
 ## If @var{parent} is omitted then a uitoolbar for the current figure is
 ## created.  If no figure is available, a new figure is created first.
@@ -34,6 +35,9 @@
 ##
 ## Uitoolbar properties are documented at @ref{Uitoolbar Properties}.
 ##
+## The optional return value @var{hui} is a graphics handle to the created
+## uitoolbar object.
+##
 ## Examples:
 ##
 ## @example
@@ -52,6 +56,11 @@
 function hui = uitoolbar (varargin)
 
   [h, args] = __uiobject_split_args__ ("uitoolbar", varargin, {"figure"});
-  hui = __go_uitoolbar__ (h, args{:});
+  
+  htmp = __go_uitoolbar__ (h, args{:});
+  
+  if (nargout > 0)
+    hui = htmp;
+  endif
 
 endfunction