|
|
[about having to "cast away" const:]
On 4/16/24 16:29 'Matthias Melcher' via fltk.general wrote:
Yes, this is a side effect of offering the shortcut to use a
statically allocated Menu Item array. You can safely cast away the
`const` once you know that your menu array was copied. To be
absolutely sure, instead of Fl_Menu_::menu(myMenu)
you can call Fl_Menu_::copy(myMenu),
and you are guaranteed that the menu array is no longer const.
To add to this statement: as soon as you add at least one menu entry
dynamically (or if you build the menu dynamically from the
beginning) the menu is always allocated in writable memory.
It is recommended to call menu_end()
after all menu modifications are done, which copies the menu from
some random internal storage to its final place [1]. After that it
is safe to get and store pointers to menu items ... until the menu
is modified again.
[1] otherwise the menu will be copied later at an unpredictable time
(e.g. when other menus are changed) but always before
it is shown by popup() etc.
--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/764e81ef-61cd-46af-8b49-165d6b4a7e7c%40aljus.de.
[ Direct Link to Message ] | |
|
| |