octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #55921] clf (hf, "reset") may fail with error


From: John W. Eaton
Subject: [Octave-bug-tracker] [bug #55921] clf (hf, "reset") may fail with error from cellfun
Date: Thu, 14 Mar 2019 12:13:19 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0

URL:
  <https://savannah.gnu.org/bugs/?55921>

                 Summary: clf (hf, "reset") may fail with error from cellfun
                 Project: GNU Octave
            Submitted by: jwe
            Submitted on: Thu 14 Mar 2019 04:13:18 PM UTC
                Category: Plotting with gnuplot
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Unexpected Error
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: dev
        Operating System: Any

    _______________________________________________________

Details:

Since the following change:


changeset:   26874:992f55ef87f5
user:        Pantxo Diribarne <address@hidden>
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:

    ## Delete all the children, including the ones with hidden handles,
    ## 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?




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?55921>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]