I've checked in a possible workaround in trunk
changeset 3446It seems to resolve the problem and not break anything else obviously, but I don't think it's really the right solution. We a large number of different variables that track the alt state in some form or other, so it's a bit confusing.
The original comment says
" Restore old handler - prevent calling MD draw after module unloaded"
It seems like it might be more to the point to just make gui_script_draw not call the MD stuff if script isn't running.
The PTP code has it's own special cases to handle scripts that enter and leave alt. There should probably be a generic script_enter_alt and script_leave_alt or something.
Another potential issue is that scriptGuiHandler is only set when the script is first run from the gui, so if you use exit_alt and enter_alt, you will never get back to the original state. PTP will also never use scriptGuiHandler, presumably meaning the MD grid will never be drawn.
The whole logic of show_md_grid is not clear to me, it looks like it's specifically set up to show briefly after script stops, but the old_gui_handler stuff is set up to override this.