On 15.05.2011 17:42, Nikita Egorov wrote:
> Hi, I'm sorry for bad news - yesterday I had found one more bug. After
> my fast glance at new RC5 I see this bug has remained.
> I don't know how about level of the bug, please judge about it yourself.
>
> The method Fl_Menu_::remove() doesn't remove last item in menu.
[...]
> You can change menubar.cxx from RC5 in such way
>
> -- mb.remove(1); // delete the "File" submenu
>
> ++ int last = mb.size()-1;
> ++ mb.remove(last);
> ++ int new_last = mb.size()-1;
>
> after executing "new_last == last" :(
I did this, and what you write is correct, but what is the *last* item
in a menu array? I think that your assumption is wrong, because size()
"returns the number of Fl_Menu_Item structures that make up the menu,
correctly counting submenus", according to the docs.
Hence there are size()-1 menu items in the array (w/o the terminating
zero item), and since menu items start counting at 0, this means:
int last = mb.size()-2; // = index to last array element.
With this change I can run the test/menubar demo, and it works
correctly, removing the "button" menu entry from the menu button
(popup).
These changed lines in test/menubar.cxx, line 210:
//mb.remove(1); // delete the "File" submenu
int last = mb.size()-2;
mb.remove(last);
int new_last = mb.size()-2;
printf ("last=%d, new_last=%d, size=%d\n", last, new_last, mb.size());
print:
last=106, new_last=105, size=107
no matter if I compile it with FLTK 1.1.11 or FLTK 1.3.0.
Albrecht
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk