bugGNU Octave - Bugs: bug #52798, set (h,...

 
 

bug #52798: set (h, "boolean_property") does not display default correctly

Submitter:  Rik <rik5>
Submitted:  Wed 03 Jan 2018 07:22:16 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed 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
   

Tue 23 Jan 2018 07:30:12 PM UTC, comment #4: 

I checked in the changeset here (http://hg.savannah.gnu.org/hgweb/octave/rev/b708857d634e).  Thanks Sahil.  I know you have another patch out for xor, but it will take me a while to review that because I've got other work responsibilities at the moment.

Marking as fixed and closing report.

Rik <rik5>
Group administrator
Tue 23 Jan 2018 11:19:52 AM UTC, comment #3: 

I think the new constructor (v2.1) that you made looks like the one just above it (constructor v1.0):
https://hg.savannah.gnu.org/hgweb/octave/file/bccb203494f6/libinterp/corefcn/graphics.in.h#l1585

I thought that this constructor(v2.0) might be used by any other macro as well which may need to call v2.0 (i.e, in its earlier form).

Anyway, if you feel this is better, then I am happy with that too.

Btw, thanks for correcting the commit message as well (I had written some real crap) and yes, my first name is Sahil. :-)

Sahil <batterylow>
Tue 23 Jan 2018 09:55:01 AM UTC, comment #2: 

@Sahil: based on your analysis I wrote a simpler patch that fixes the property constructor instead of using another one. Just to be sure, is Sahil your first name (so that your are added at the right place in the contributors)?


(file #43032)

Pantxo Diribarne <pantxo>
Group Member
Mon 22 Jan 2018 02:09:46 PM UTC, comment #1: 

I was trying to do something else when I got stuck on this very problem.

The problem was in ./libinterp/corefcn/graphics.in.h where the bool property were initialised using this :


bool_property beingdeleted , "off"


which called this constructor:

  bool_property (const std::string& nm, const graphics_handle& h,
                 const char *val)
      : radio_property (nm, h, radio_values ("on|off"), val)


due to which, while evaluating the property in this :
https://hg.savannah.gnu.org/hgweb/octave/file/bccb203494f6/libinterp/corefcn/graphics.cc#l1206
always the 'else if' part was being executed because our string was "on|off".

Now, I have changed the initialising macros to the other type which require a bool type of argument and so the string that is passed is based on the 'val' of the bool argument as:

  bool_property (const std::string& nm, const graphics_handle& h,
                 bool val)
    : radio_property (nm, h, radio_values (val ? "{on}|off" : "on|{off}")


Hence, the patch serves the goal. Hope it will help.

(file #43019)

Sahil <batterylow>
Wed 03 Jan 2018 07:22:16 PM UTC, original submission:  

Boolean graphics properties take the value of "on" or "off".  The set (graphic_handle, "property_name") is supposed to list all of the possible values the property can take along with the default value wrapped in '{}'.

For boolean properties, it always wraps the second value of "on" with "{}".  Sample code with property "beingdeleted" which has a default of "off" and "clipping" which has a default of "on".


octave:1> set (0, "beingdeleted")
[ off | {on} ]
octave:2> set (0, "clipping")
[ off | {on} ]


Interestingly, the documentation in the Octave manual gets this right.

Rik <rik5>
Group administrator

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #43032:  boolprop_default.patch added by pantxo (1KiB - text/x-patch)
file #43019:  52798.diff added by batterylow (14KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by pantxo (Updated the item)
  • -email is unavailable- added by batterylow (Updated the item)
  • -email is unavailable- added by rik5 (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-01-23 rik5 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2018-01-23 pantxo Attached File- Added boolprop_default.patch, #43032
        StatusNone Patch Submitted
    2018-01-22 batterylow Attached File- Added 52798.diff, #43019

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code