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

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

[Octave-bug-tracker] [bug #49980] plotyy fails after previous plot


From: Rik
Subject: [Octave-bug-tracker] [bug #49980] plotyy fails after previous plot
Date: Wed, 4 Jan 2017 01:44:44 +0000 (UTC)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0

Update of bug #49980 (project octave):

                  Status:                    None => Confirmed              

    _______________________________________________________

Follow-up Comment #1:

Confirmed.

The problem is that there is a listener added to the axes object which will
change the color of the labels when the axes color property is changed.

When you call any graphics function, one of the first things it does it call
newplot() to either get a new axes object or reuse an existing one.  If
newplot decides to reuse an existing object it resets the default properties
of the object.  The sequence of events is hard to follow but eventually the
C++ function __go_axes_init__ in graphics.cc is called.  The issue is that the
C++ function does not include removing listeners on the axes object.  

When an attempt to change the axes color property is made by plotyy the old
callback fires, but the ylabel that it pointed to is gone and so you get an
error.

A simpler example to reproduce the error is:


plot (1:4)
ylabel ('y')
plot (1:10)
set (gca, "ycolor", 'r')


I have two possible fixes.  The correct way to fix this is to call
remove_all_listeners() on the axes graphics_object.  Unfortunately, the
required function is part of the class base_graphics_object and is not
exposed.  In order to call it, the API for the class graphics_object needs to
have a public function remove_all_listeners which calls the
base_grahpics_object function of the same name.  This would be a change to the
internal API which is normally only made when Octave changes minor versions
(say from 4.2 to 4.4).  I've added jwe to the CC list so that he can comment
on whether it would be acceptable in this instance.  The attached file
rm_all_listen.patch implements this approach.

The second approach modifies the callback function to check whether the handle
is valid before calling set() to change the color.  The attached file
cb_color.patch implements this method.  The problem with this is that the
callback will still be called every time something modifies the color
properties of the axes.  If you do a series of several plots which re-use the
same axes and all have labels or titles then the callback could be invoked a
lot.



(file #39360, file #39361)
    _______________________________________________________

Additional Item Attachment:

File name: rm_all_listen.patch            Size:0 KB
File name: cb_color.patch                 Size:0 KB


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?49980>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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