Skip to content

menu_find_by_name() creates a menu if the name isn't found #255

Description

@reticulatedpines

This is insane behaviour. It's by design. We should change this, maybe so it looks more like this:

    if (!menu_find_by_name( "Audio"))
        menu_create("Audio", ICON_ML_AUDIO);

Note that it also works as a function to update the icon. Therefore it should really be called menu_find_or_create_by_name_and_update_icon(). Thus we should also split out menu_update_icon().

When that is done, we can remove static qualifier from menu_find_by_name(). Then we can find all uses of this kind of pattern: lens_info_menus[0].children[0].parent_menu->split_pos = -10; and make them more readable and much less fragile. I've broken code in the past by re-ordering menu items and not realising some other file had hard-coded the index of something it wanted to modify.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions