On 18.07.2011 08:42, Manolo Gouy wrote:
>> Manolo, since you did that particular change, I assume that you are more
>> familiar with this code, and I'd like to see your comment (or a better
>> solution).
>>
>> Here's a simple test case: use this patch to add an invisible menu item to
>> the menu button in test/menubar.cxx, compile and run it, then click on the
>> menu button. The application goes into an endless loop...
>>
>> --- test/menubar.cxx    (revision 8862)
>> +++ test/menubar.cxx    (working copy)
>> @@ -176,6 +176,7 @@
>>     {"&Charm",   FL_ALT+'c'},
>>     {"Truth",    FL_ALT+'t'},
>>     {"Beauty",   FL_ALT+'b'},
>> +  {0,0, 0, 0, FL_MENU_INVISIBLE},
>>     {0}
>>   };
>
> I don't think it's correct to define an Fl_Menu_Item with 0 in first
> field (name) and non-zero somewhere else, because 0-named items
> are used everywhere in the code as markers of submenu end.
> See, e.g., Fl_Menu.cxx lines 46, 316, 334.
> Accepting that would require much rewriting, for a dubious benefit.

Thanks for your comment.

I agree with you that this is unusual or may even look wrong, but there
are three reasons why I believe that it would be worth fixing:

(1) it works in FLTK 1.1 and worked in 1.3 up to and including RC3

(2) it fails in a bad way (GUI freeze, endless CPU loop)

(3) I believe that a zero item name (text == NULL) should always
terminate a (sub)menu, regardless of the contents of any other field
in the Fl_Menu_Item structure. It worked that way before svn r8639,
and that's why the user found this.
Documentation of "const char* Fl_Menu_Item::label() const" states:
"A NULL here indicates the end of the menu (or of a submenu)."
See 
<http://www.fltk.org/doc-1.3/structFl__Menu__Item.html#ab7a334e6bf9d8ead1c8f1f20a70b0296>
There is no mention of restrictions of other menu fields, and thus
it *should* terminate the (sub)menu definitely.

Unfortunately the change in r8639 made this fail, so if you can
fix it (maybe in a better way than I did?), then please do it.
Thanks.

Albrecht
_______________________________________________
fltk-bugs mailing list
fltk-bugs@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk-bugs

Reply via email to