bugGNU Octave - Bugs: bug #55921, clf (hf, "reset") may...

 
 

bug #55921: clf (hf, "reset") may fail with error from cellfun

Submitter:  John W. Eaton <jwe>
Submitted:  Thu 14 Mar 2019 04:13:18 PM UTC
   
 
Category:  Plotting with gnuplot Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
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
   

Thu 14 Mar 2019 06:34:03 PM UTC, comment #2: 

Verified the fix works.  Closing report.

Rik <rik5>
Group administrator
Thu 14 Mar 2019 04:28:27 PM UTC, comment #1: 
John W. Eaton <jwe>
Group administrator
Thu 14 Mar 2019 04:13:18 PM UTC, original submission:  

Since the following change:


changeset:   26874:992f55ef87f5
user:        Pantxo Diribarne <pantxo.diribarne@gmail.com>
date:        Thu Mar 07 22:53:33 2019 +0100
summary:     Use an uitoolbar and ui*tools to build the default figure toolbar (bug #55795)


I see the following error:


octave:1> graphics_toolkit gnuplot
octave:2> hf = figure ()
hf =  1
octave:3> clf ("reset")
error: kids(1): out of bound 0
error: called from
    clf at line 84 column 5


This happens because _add_default_menu_ now returns early for gnuplot, so the figure has just one child and clf does this:


    ## except default menus and toolbar.
    kids = allchild (hfig);
    ismenu = cellfun (@(s) strncmp (s, "__default_menu_", 15), ...
                      get (kids, "tag"));


and "get" returns a single item here instead of a cell array.

My first thought was to undo this hunk of cset 992f55ef87f5


diff --git a/scripts/plot/util/private/__add_default_menu__.m b/scripts/plot/util/private/__add_default_menu__.m
--- a/scripts/plot/util/private/__add_default_menu__.m
+++ b/scripts/plot/util/private/__add_default_menu__.m
@@ -28,7 +28,12 @@

 ## Author: Kai Habel

-function __add_default_menu__ (hf, hmenu = [])
+function __add_default_menu__ (hf, hmenu = [], htb = [])
+
+  ## Gnuplot doesn't handle uimenu and uitoolbar objects
+  if (strcmp (graphics_toolkit (), "gnuplot"))
+    return
+  endif

   ## Create
   if (isempty (hmenu))


but then I see this error when attempting to create a figure:


octave:1> graphics_toolkit gnuplot
octave:2> hf = figure ()
hf =  1
error: __gnuplot_draw_figure__: unknown object class, uitoolbar
error: called from
    __gnuplot_draw_figure__ at line 179 column 13
    __gnuplot_drawnow__ at line 86 column 5


And I also realized that it is probably possible for users to create figures without toolbars, regardless of the toolkit, so we may have to fix all our code that works on figure properties in this way to be careful to handle the case of a single child.

I assume that get works this way (only returning a cell if there is more than one handle) for compatibility with Matlab, so we can't just change it to always return a cell array.

I'll attach a patch for clf when I get a bug number.

Are there other cases where this kind of problem may occur?

John W. Eaton <jwe>
Group administrator

 

(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 jwe (Submitted the item)
  • -email is unavailable- added by jwe
  •  

    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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-03-14 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2019-03-14 jwe StatusNone Ready For Test
    2019-03-14 jwe Carbon-Copy- Added panxto

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code