Karsten Hopp 899429
To: vim-dev@vim.org
Karsten Hopp 899429
Subject: Patch 7.0.062
Karsten Hopp 899429
Fcc: outbox
Karsten Hopp 899429
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 899429
Mime-Version: 1.0
Karsten Hopp 899429
Content-Type: text/plain; charset=ISO-8859-1
Karsten Hopp 899429
Content-Transfer-Encoding: 8bit
Karsten Hopp 899429
------------
Karsten Hopp 899429
Karsten Hopp 899429
Patch 7.0.062
Karsten Hopp 899429
Problem:    Mac: Crash when using the popup menu for spell correction.  The
Karsten Hopp 899429
	    popup menu appears twice when letting go of the right mouse button
Karsten Hopp 899429
	    early.
Karsten Hopp 899429
Solution:   Don't show the popup menu on the release of the right mouse
Karsten Hopp 899429
	    button.  Also check that a menu pointer is actually valid.
Karsten Hopp 899429
Files:	    src/proto/menu.pro, src/menu.c, src/normal.c, src/term.c
Karsten Hopp 899429
Karsten Hopp 899429
Karsten Hopp 899429
*** ../vim-7.0.061/src/proto/menu.pro	Fri Mar 24 23:37:59 2006
Karsten Hopp 899429
--- src/proto/menu.pro	Wed Aug 16 20:25:57 2006
Karsten Hopp 899429
***************
Karsten Hopp 899429
*** 10,15 ****
Karsten Hopp 899429
--- 10,16 ----
Karsten Hopp 899429
  extern int menu_is_child_of_popup __ARGS((vimmenu_T *menu));
Karsten Hopp 899429
  extern int menu_is_toolbar __ARGS((char_u *name));
Karsten Hopp 899429
  extern int menu_is_separator __ARGS((char_u *name));
Karsten Hopp 899429
+ extern int check_menu_pointer __ARGS((vimmenu_T *root, vimmenu_T *menu_to_check));
Karsten Hopp 899429
  extern void gui_create_initial_menus __ARGS((vimmenu_T *menu));
Karsten Hopp 899429
  extern void gui_update_menus __ARGS((int modes));
Karsten Hopp 899429
  extern int gui_is_menu_shortcut __ARGS((int key));
Karsten Hopp 899429
*** ../vim-7.0.061/src/menu.c	Wed Aug 16 15:56:58 2006
Karsten Hopp 899429
--- src/menu.c	Wed Aug 16 20:35:09 2006
Karsten Hopp 899429
***************
Karsten Hopp 899429
*** 1778,1783 ****
Karsten Hopp 899429
--- 1778,1804 ----
Karsten Hopp 899429
  }
Karsten Hopp 899429
  
Karsten Hopp 899429
  /*
Karsten Hopp 899429
+  * Check that a pointer appears in the menu tree.  Used to protect from using
Karsten Hopp 899429
+  * a menu that was deleted after it was selected but before the event was
Karsten Hopp 899429
+  * handled.
Karsten Hopp 899429
+  * Return OK or FAIL.  Used recursively.
Karsten Hopp 899429
+  */
Karsten Hopp 899429
+     int
Karsten Hopp 899429
+ check_menu_pointer(root, menu_to_check)
Karsten Hopp 899429
+     vimmenu_T *root;
Karsten Hopp 899429
+     vimmenu_T *menu_to_check;
Karsten Hopp 899429
+ {
Karsten Hopp 899429
+     vimmenu_T	*p;
Karsten Hopp 899429
+ 
Karsten Hopp 899429
+     for (p = root; p != NULL; p = p->next)
Karsten Hopp 899429
+ 	if (p == menu_to_check
Karsten Hopp 899429
+ 		|| (p->children != NULL
Karsten Hopp 899429
+ 		    && check_menu_pointer(p->children, menu_to_check) == OK))
Karsten Hopp 899429
+ 	    return OK;
Karsten Hopp 899429
+     return FAIL;
Karsten Hopp 899429
+ }
Karsten Hopp 899429
+ 
Karsten Hopp 899429
+ /*
Karsten Hopp 899429
   * After we have started the GUI, then we can create any menus that have been
Karsten Hopp 899429
   * defined.  This is done once here.  add_menu_path() may have already been
Karsten Hopp 899429
   * called to define these menus, and may be called again.  This function calls
Karsten Hopp 899429
*** ../vim-7.0.061/src/normal.c	Sat Apr 29 23:53:55 2006
Karsten Hopp 899429
--- src/normal.c	Wed Aug 16 19:54:04 2006
Karsten Hopp 899429
***************
Karsten Hopp 899429
*** 2504,2510 ****
Karsten Hopp 899429
  	     * NOTE: Ignore right button down and drag mouse events.
Karsten Hopp 899429
  	     * Windows only shows the popup menu on the button up event.
Karsten Hopp 899429
  	     */
Karsten Hopp 899429
! #if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON)
Karsten Hopp 899429
  	    if (!is_click)
Karsten Hopp 899429
  		return FALSE;
Karsten Hopp 899429
  #endif
Karsten Hopp 899429
--- 2504,2511 ----
Karsten Hopp 899429
  	     * NOTE: Ignore right button down and drag mouse events.
Karsten Hopp 899429
  	     * Windows only shows the popup menu on the button up event.
Karsten Hopp 899429
  	     */
Karsten Hopp 899429
! #if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) \
Karsten Hopp 899429
! 			  || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_MAC)
Karsten Hopp 899429
  	    if (!is_click)
Karsten Hopp 899429
  		return FALSE;
Karsten Hopp 899429
  #endif
Karsten Hopp 899429
*** ../vim-7.0.061/src/term.c	Wed May  3 23:26:49 2006
Karsten Hopp 899429
--- src/term.c	Wed Aug 16 21:24:21 2006
Karsten Hopp 899429
***************
Karsten Hopp 899429
*** 4783,4788 ****
Karsten Hopp 899429
--- 4783,4796 ----
Karsten Hopp 899429
  		return -1;
Karsten Hopp 899429
  	    current_menu = (vimmenu_T *)val;
Karsten Hopp 899429
  	    slen += num_bytes;
Karsten Hopp 899429
+ 
Karsten Hopp 899429
+ 	    /* The menu may have been deleted right after it was used, check
Karsten Hopp 899429
+ 	     * for that. */
Karsten Hopp 899429
+ 	    if (check_menu_pointer(root_menu, current_menu) == FAIL)
Karsten Hopp 899429
+ 	    {
Karsten Hopp 899429
+ 		key_name[0] = KS_EXTRA;
Karsten Hopp 899429
+ 		key_name[1] = (int)KE_IGNORE;
Karsten Hopp 899429
+ 	    }
Karsten Hopp 899429
  	}
Karsten Hopp 899429
  # endif
Karsten Hopp 899429
  # ifdef FEAT_GUI_TABLINE
Karsten Hopp 899429
*** ../vim-7.0.061/src/version.c	Wed Aug 16 21:26:19 2006
Karsten Hopp 899429
--- src/version.c	Wed Aug 16 21:40:37 2006
Karsten Hopp 899429
***************
Karsten Hopp 899429
*** 668,669 ****
Karsten Hopp 899429
--- 668,671 ----
Karsten Hopp 899429
  {   /* Add new patch number below this line */
Karsten Hopp 899429
+ /**/
Karsten Hopp 899429
+     62,
Karsten Hopp 899429
  /**/
Karsten Hopp 899429
Karsten Hopp 899429
-- 
Karsten Hopp 899429
hundred-and-one symptoms of being an internet addict:
Karsten Hopp 899429
166. You have been on your computer soo long that you didn't realize
Karsten Hopp 899429
     you had grandchildren.
Karsten Hopp 899429
Karsten Hopp 899429
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 899429
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 899429
\\\        download, build and distribute -- http://www.A-A-P.org        ///
Karsten Hopp 899429
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///