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

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

[Octave-bug-tracker] [bug #44801] Removing a context menu


From: Rik
Subject: [Octave-bug-tracker] [bug #44801] Removing a context menu
Date: Fri, 10 Apr 2015 22:33:12 +0000
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:37.0) Gecko/20100101 Firefox/37.0

Update of bug #44801 (project octave):

                  Status:                    None => Confirmed              

    _______________________________________________________

Follow-up Comment #1:

The problem appears to be that the C++ graphics code assumes that whenever an
object is deleted it should be removed from it's parent's "children" property.
 In this case, the graphics handle for the menu is under the "uicontextmenu"
rather than "children.

You can hack around this for now, or dive into the source if it is really
bothersome.

First, delete() is the correct thing to do to remove a handle so


delete (c)


will rid Octave of the uicontextmenu.  The 'uicontextmenu' property expects a
graphics_handle to be entered.  This is a double value, where NaN has the
special meaning of invalid.  At some point, libinterp/corefcn/graphics.in.h
should be modified to accept an empty matrix input ([]).  For now, this will
safely rid the figure of the now deleted uicontextmenu.


set (F, 'uicontextmenu', NaN)


As a workaround that combines these two things you could write a special
deletefcn to be called whenever a uicontextmenu is deleted.


function cb_delete_uicontextmenu (h)
  p = get (h, "parent");
  set (p, "uicontextmenu", NaN);
  delete (h);
endfunction


Now you can write


% By default, uicontextmenu is []
F = figure;
get(F,'uicontextmenu')

% add a uicontextmenu
c = uicontextmenu;
set (c, "deletefcn", @cb_delete_uicontextmenu);
m = uimenu('parent',c,'label','menu');
set(F,'uicontextmenu',c);

% Now delete and check that object is gone
delete (c)
get (c)
get(F,'uicontextmenu')


Since uicontextmenu is an m-file in scripts/gui this could be made a default
part of Octave.  Or the C++ deletion code in graphics.in.h could be improved. 
The destructor ~uicontextmenu is currently empty.  Maybe that is the place to
check the parent and see if there is a 'uicontextmenu' property and delete it,
rather than in an m-file callback.



    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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