# HG changeset patch # User vimboss # Date 1155757268 0 # Node ID 77f8a648d2e6c765329ee6544bd8716835bda3bb # Parent c8cae82dee305d003f809d91025ed21582785597 updated for version 7.0-062 diff --git a/src/menu.c b/src/menu.c --- a/src/menu.c +++ b/src/menu.c @@ -1778,6 +1778,27 @@ get_menu_mode() } /* + * Check that a pointer appears in the menu tree. Used to protect from using + * a menu that was deleted after it was selected but before the event was + * handled. + * Return OK or FAIL. Used recursively. + */ + int +check_menu_pointer(root, menu_to_check) + vimmenu_T *root; + vimmenu_T *menu_to_check; +{ + vimmenu_T *p; + + for (p = root; p != NULL; p = p->next) + if (p == menu_to_check + || (p->children != NULL + && check_menu_pointer(p->children, menu_to_check) == OK)) + return OK; + return FAIL; +} + +/* * After we have started the GUI, then we can create any menus that have been * defined. This is done once here. add_menu_path() may have already been * called to define these menus, and may be called again. This function calls diff --git a/src/normal.c b/src/normal.c --- a/src/normal.c +++ b/src/normal.c @@ -2504,7 +2504,8 @@ do_mouse(oap, c, dir, count, fixindent) * NOTE: Ignore right button down and drag mouse events. * Windows only shows the popup menu on the button up event. */ -#if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) || defined(FEAT_GUI_PHOTON) +#if defined(FEAT_GUI_MOTIF) || defined(FEAT_GUI_GTK) \ + || defined(FEAT_GUI_PHOTON) || defined(FEAT_GUI_MAC) if (!is_click) return FALSE; #endif diff --git a/src/proto/menu.pro b/src/proto/menu.pro --- a/src/proto/menu.pro +++ b/src/proto/menu.pro @@ -10,6 +10,7 @@ extern int menu_is_popup __ARGS((char_u extern int menu_is_child_of_popup __ARGS((vimmenu_T *menu)); extern int menu_is_toolbar __ARGS((char_u *name)); extern int menu_is_separator __ARGS((char_u *name)); +extern int check_menu_pointer __ARGS((vimmenu_T *root, vimmenu_T *menu_to_check)); extern void gui_create_initial_menus __ARGS((vimmenu_T *menu)); extern void gui_update_menus __ARGS((int modes)); extern int gui_is_menu_shortcut __ARGS((int key)); diff --git a/src/term.c b/src/term.c --- a/src/term.c +++ b/src/term.c @@ -4783,6 +4783,14 @@ check_termcode(max_offset, buf, buflen) return -1; current_menu = (vimmenu_T *)val; slen += num_bytes; + + /* The menu may have been deleted right after it was used, check + * for that. */ + if (check_menu_pointer(root_menu, current_menu) == FAIL) + { + key_name[0] = KS_EXTRA; + key_name[1] = (int)KE_IGNORE; + } } # endif # ifdef FEAT_GUI_TABLINE diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -667,6 +667,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 62, +/**/ 61, /**/ 60,