I'm also seeing menu glitches sometimes, it's not exclusive to user menu.
Just to be clear, do you have the user menu enabled and you are seeing glitches in other menus? Or is it disabled and you are seeing glitches? (I only spent a little time looking at the code but I believe that what I saw is related to how the MENU key is handled in different menu modes)
On a camera where the Miscellaneous -> SD card menu has only one entry, clicking "make card bootable" pops up a messagebox. Dismissing that box only makes the menu redraw, but nothing is redrawn outside the menu. Not related to user menu.
What is the likelihood of multiple modules wanting to register? Do you need to allow more than one registration?
I've been thinking about this, but the current code can only handle one such pointer. The registration is done by the module, in its init function, and it resets this pointer (to NULL) right before unloading. Since I have listed 3 examples above, handling multiple modules would not be bad.
Is gui_draw_debug_vals_osd the best place to call it?
Maybe not, but it was my first idea, and it works almost the way it should (i.e. it respects the CHDK menu).
Your change might even allow the debug code to be moved to a module using this hook.
Yes, that was obvious, although the keyboard handling would need some thoughts.
How do you control the module once its loaded and 'run' has been called? The other simple modules take over the gui and kbd while running; but it seems these types of modules would not be able to trap any button presses, so how do you shut down the module when your done with it?
The module registers one of its own draw functions as the callback. I simply start it again (which calls the already loaded instance), and use its functions to make it unload (by pressing MENU).