This caters for the scenario where the module is loaded with gui_menu_run_fltmodule to access it's sub-menus. In this case the function in 'modules.c' was not used to load the module so it's bind function was not called. If the module is not unloaded when the menus exit this ensures the bind function is called for the already loaded module.
I see. Then for correct processing this scenario module flags should be refreshed with bitwise OR in module_load.
Because generic_flt_run will run with no flags, and then in described case loaded module could be unloaded unsafely later.
The menu code only unloads modules that have the module index stored in the menu stack array (see the call to gui_activate_sub_menu). DNG does not have a menu so is not affected by this - there is no change to the DNG load/unload behaviour.
load/unload behaviour is changed because MODULE_FLAG_DISABLE_AUTOUNLOAD is cleaned in modules.c. So it will be unloaded on simple sequence "go to ALT mode - goto NONE mode".
I'm not sure why did you set flag MODULE_FLAG_DISABLE_AUTOUNLOAD for zebra, but would like to note just in case that this flag will not prevent unloading when leave its submenu.
Unloading the module when exiting the menu ensures the config changes get saved - the module will be re-loaded when next used. If the zebra was turned off then it won't get re-loaded and so this also serves to automatically release the module if it is no longer needed (same applies for edge overlay).
I thought setting the flag was to ensure the module did not get unloaded during normal operation?
I do agree with your unloading scenario for modules with submenus. Different one (on menu item value change like for DNG) could be unsafe if trigger is placed in modularized submenu.
I'm not sure what do you mean saying "normal operation", but meaning and purpose of this flag is preventing unload module on global special case "leave CHDK gui mode (switch to GUI_MODE_NONE)". This was only one case when CHDK knew nothing about unloaded module.
What is for: for example I run game then press ALT button and goto "none" mode. Gui mode is switched and automatically will not get back to module and so this game left unloaded. To prevent this I do unload all modules except flagged (which couldn't be safely unloaded in some processing).