CnPCaret fix for crash on menu deletion. Implement Rob Sprowson's improvement...
Fix crash on closing menu that contains a focussed writeable icon as part of the menu tree (rather than in a window)
- when closing menus, set_caret_position is called to remove the caret from the menu tree
- this tries to redraw the icon without a caret as the window is still defined and valid
- this happens after clearing the menutaskhandle though so the redraw can't page in the right task
- the redraw then fails badly trying to access memory from the wrong task
The fix ensures the correct task is pages in before calling int_set_icon_state when redrawing. If it's a menu window, then it checks the menutaskhandle entry. If this is -4 then the menu tree is being deleted, so we don't need to redraw anything and should abandon gracefully.