bugGNU Octave - Bugs: bug #64092, ishghandle returns true for...

 
 

bug #64092: ishghandle returns true for non-handle variables with same value as open figure

Submitter:  Nicholas Jankowski <nrjank>
Submitted:  Sat 22 Apr 2023 08:18:45 PM UTC
   
 
Category:  Octave Function Severity:  2 - Minor
Priority:  3 - Low Item Group:  Other
Status:  Wont Fix Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 26 Apr 2023 12:37:02 AM UTC, comment #12: 

This has to stay the way it is for Matlab compatibility.  Marking as "Won't Fix" and closing report.

Rik <rik5>
Group administrator
Mon 24 Apr 2023 03:57:51 PM UTC, comment #11: 

understood. this initial report stemmed from me trying to make an input validation that could distinguish between the first argument being a graphics handle or a numeric input, and the overlap caught me by surprise. ok if this should just get closed as invalid, and will move more general inquiry over to discourse. (see https://octave.discourse.group/t/ishandle-returning-true-if-non-handle-has-same-value/4392 )

Nicholas Jankowski <nrjank>
Group Member
Mon 24 Apr 2023 03:25:54 AM UTC, comment #10: 

I lowered the Priority and Severity of this report.  Both Octave and Matlab have used doubles to refer to graphics handles for decades with, apparently, very few problems.  There is the potential to mistake a figure graphics handle for an integer double input, but it doesn't seem to happen much in practice.

Rik <rik5>
Group administrator
Sun 23 Apr 2023 05:32:04 AM UTC, comment #9: 

You can still use double values to reference graphics objects in Matlab. At least that was true but too long ago.

Markus Mützel <mmuetzel>
Group administrator
  Spam posted by anonymous
Sat 22 Apr 2023 10:05:44 PM UTC, comment #7: 

seems it makes sense that it should accept a figure handle.  and matlab does. since they switched to handle objects, though, they no longer have any conflicts with integer doubles.

Nicholas Jankowski <nrjank>
Group Member
Sat 22 Apr 2023 10:01:17 PM UTC, comment #6: 

ok, is quiver(gcf, 1,2) valid usage?  the help says specifically that the first input can optionally be an axes handle.  a figure handle doesn't fail. should it? with the limits below, could it?

Nicholas Jankowski <nrjank>
Group Member
Sat 22 Apr 2023 09:58:56 PM UTC, comment #5: 

ok looking at plt_get_axis_arg, it checks


  if (! isempty (varargin) && isscalar (varargin{1})
      && ishghandle (varargin{1}) && varargin{1} != 0
      && ! isfigure (varargin{1}))


so a yes on ishghandle, but then uses isfigure to notch out any integer valued doubles that might overlap with a false ishghandle positive. since most people call with an axes handle, and that's a random negative scalar non-integer double, it wouldn't trigger.

so something like quiver(gcf ,1,2), which is a valid usage, would still fail a  `ishghandle (varargin{1}) && ! isfigure (varargin{1})` test.

Nicholas Jankowski <nrjank>
Group Member
Sat 22 Apr 2023 09:45:52 PM UTC, comment #4: 

ok. so is there a way to distinguish whether the first input of

quiver(gca, 1, 2)

or

quiver(1, 2, 3)

is a graphics handle without first overwriting than graphics handle? (as it currently does in _plt_get_axis_arg_)

Nicholas Jankowski <nrjank>
Group Member
Sat 22 Apr 2023 09:29:33 PM UTC, comment #3: 

That is expected behavior.  In Octave, as in older versions of Matlab before graphics objects were re-implemented as classdef (or similar) objects, graphics handles are just double precision numbers that serve as a way to identify graphics objects.

John W. Eaton <jwe>
Group administrator
Sat 22 Apr 2023 09:09:07 PM UTC, comment #2: 

retitled since both ishandle and isgraphics are just wrappers to ishghandle for this issue.

Nicholas Jankowski <nrjank>
Group Member
Sat 22 Apr 2023 08:39:31 PM UTC, comment #1: 

in addition, simply:


>> ishandle(1)
ans = 1


Nicholas Jankowski <nrjank>
Group Member
Sat 22 Apr 2023 08:18:45 PM UTC, original submission:  

example code:


>> a = 1
a = 1
>> ishandle(a)
ans = 0
>> figure
>> gcf
ans = 1
>> ishandle(a)
ans = 1
>> ishghandle(a)
ans = 1
>> isgraphics(a)
ans = 1


Nicholas Jankowski <nrjank>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by nrjank (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-04-26 rik5 StatusConfirmed Wont Fix
        Open/ClosedOpen Closed
    2023-04-24 rik5 Severity3 - Normal 2 - Minor
        Priority5 - Normal 3 - Low
        Item GroupNone Other
        StatusNone Confirmed
    2023-04-22 nrjank Summaryishandle returns true for non-handle variables with same value as open figure ishghandle returns true for non-handle variables with same value as open figure

    Back to the top

    Powered by Savane 3.13-cf05.
    Corresponding source code