diff src/menubar-x.c @ 1918:59bf16be00bf

[xemacs-hg @ 2004-02-19 02:49:18 by james] Protect against menubar computations within redisplay.
author james
date Thu, 19 Feb 2004 02:49:20 +0000
parents 01c57eb70ae9
children 04bc9d2f42c7
line wrap: on
line diff
--- a/src/menubar-x.c	Wed Feb 18 22:50:49 2004 +0000
+++ b/src/menubar-x.c	Thu Feb 19 02:49:20 2004 +0000
@@ -336,23 +336,6 @@
   return wv;
 }
 
-static widget_value *
-menu_item_descriptor_to_widget_value (Lisp_Object desc,
-				      int menu_type, /* if this is a menubar,
-							popup or sub menu */
-				      int deep_p,    /*  */
-				      int filter_p)  /* if :filter forms
-							should run now */
-{
-  widget_value *wv;
-  int count = begin_gc_forbidden ();
-  /* Can't GC! */
-  wv = menu_item_descriptor_to_widget_value_1 (desc, menu_type, deep_p,
-					       filter_p, 0);
-  unbind_to (count);
-  return wv;
-}
-
 struct menu_item_descriptor_to_widget_value
 {
   Lisp_Object desc;
@@ -365,11 +348,14 @@
 {
   struct menu_item_descriptor_to_widget_value *midtwv =
     (struct menu_item_descriptor_to_widget_value *) gack;
-
-  midtwv->wv = menu_item_descriptor_to_widget_value (midtwv->desc,
-						     midtwv->menu_type,
-						     midtwv->deep_p,
-						     midtwv->filter_p);
+  int count = begin_gc_forbidden ();
+  /* Can't GC! */
+  midtwv->wv = menu_item_descriptor_to_widget_value_1 (midtwv->desc,
+						       midtwv->menu_type,
+						       midtwv->deep_p,
+						       midtwv->filter_p,
+						       0);
+  unbind_to (count);
   return Qnil;
 }
 
@@ -405,6 +391,36 @@
   return midtwv.wv;
 }
 
+/* The two callers of menu_item_descriptor_to_widget_value may both run while
+   in redisplay.  Some descriptor to widget value conversions call Feval, and
+   at least one calls QUIT.  Hence, we have to establish protection here.. */
+
+static widget_value *
+menu_item_descriptor_to_widget_value (Lisp_Object desc,
+				      int menu_type, /* if this is a menubar,
+							popup or sub menu */
+				      int deep_p,    /*  */
+				      int filter_p)  /* if :filter forms
+							should run now */
+{
+  struct menu_item_descriptor_to_widget_value midtwv;
+  Lisp_Object retval;
+
+  midtwv.desc = desc;
+  midtwv.menu_type = menu_type;
+  midtwv.deep_p = deep_p;
+  midtwv.filter_p = filter_p;
+
+  retval = call_trapping_problems
+    (Qevent, "Error during menu construction", 0, NULL,
+     protected_menu_item_descriptor_to_widget_value_1, &midtwv);
+
+  if (UNBOUNDP (retval))
+    return NULL;
+
+  return midtwv.wv;
+}
+
 /* The order in which callbacks are run is funny to say the least.
    It's sometimes tricky to avoid running a callback twice, and to
    avoid returning prematurely.  So, this function returns true