aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2002-11-01 20:13:54 +0000
committerStefan Monnier2002-11-01 20:13:54 +0000
commit86fad4ec405473d3e8c1c72532f38779b68f4c1f (patch)
treea5af450bc6092a4f794be083d8db8d6a5fe0c96a
parent97098195f236fbbcdb09cfeec483ae1e6fcb0df2 (diff)
downloademacs-86fad4ec405473d3e8c1c72532f38779b68f4c1f.tar.gz
emacs-86fad4ec405473d3e8c1c72532f38779b68f4c1f.zip
(unuse_menu_items): New fun.
(menu_items_inuse): New var. (syms_of_xmenu): Initialize it. (init_menu_items): Use it to detect re-entrance. (Fx_popup_menu, Fx_popup_dialog, set_frame_menubar): Reset it when done. (Fx_popup_menu): Remove spurious XSETFRAME.
-rw-r--r--src/ChangeLog11
-rw-r--r--src/xmenu.c31
2 files changed, 37 insertions, 5 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 9709863303a..3a81632c844 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,14 @@
12002-11-01 Stefan Monnier <monnier@cs.yale.edu>
2
3 * xmenu.c (unuse_menu_items): New fun.
4 (menu_items_inuse): New var.
5 (syms_of_xmenu): Initialize it.
6 (init_menu_items): Use it to detect re-entrance.
7 (Fx_popup_menu, Fx_popup_dialog, set_frame_menubar): Reset it when done.
8 (Fx_popup_menu): Remove spurious XSETFRAME.
9
10 * editfns.c (find_field): Make an exception for nil fields.
11
12002-11-01 Dave Love <fx@gnu.org> 122002-11-01 Dave Love <fx@gnu.org>
2 13
3 * m/gec63.h: Deleted. 14 * m/gec63.h: Deleted.
diff --git a/src/xmenu.c b/src/xmenu.c
index 75584afc079..b8066d015d8 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -174,6 +174,10 @@ enum menu_item_idx
174 174
175static Lisp_Object menu_items; 175static Lisp_Object menu_items;
176 176
177/* If non-nil, means that the global vars defined here are already in use.
178 Used to detect cases where we try to re-enter this non-reentrant code. */
179static Lisp_Object menu_items_inuse;
180
177/* Number of slots currently allocated in menu_items. */ 181/* Number of slots currently allocated in menu_items. */
178static int menu_items_allocated; 182static int menu_items_allocated;
179 183
@@ -241,6 +245,9 @@ init_menu_items ()
241 menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil); 245 menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil);
242 } 246 }
243 247
248 if (!NILP (menu_items_inuse))
249 error ("Trying to use a menu from within a menu-entry");
250 menu_items_inuse = Qt;
244 menu_items_used = 0; 251 menu_items_used = 0;
245 menu_items_n_panes = 0; 252 menu_items_n_panes = 0;
246 menu_items_submenu_depth = 0; 253 menu_items_submenu_depth = 0;
@@ -253,6 +260,12 @@ finish_menu_items ()
253{ 260{
254} 261}
255 262
263static Lisp_Object
264unuse_menu_items (dummy)
265{
266 return menu_items_inuse = Qnil;
267}
268
256/* Call when finished using the data for the current menu 269/* Call when finished using the data for the current menu
257 in menu_items. */ 270 in menu_items. */
258 271
@@ -266,6 +279,7 @@ discard_menu_items ()
266 menu_items = Qnil; 279 menu_items = Qnil;
267 menu_items_allocated = 0; 280 menu_items_allocated = 0;
268 } 281 }
282 xassert (NILP (menu_items_inuse));
269} 283}
270 284
271/* Make the menu_items vector twice as large. */ 285/* Make the menu_items vector twice as large. */
@@ -699,6 +713,7 @@ cached information about equivalent key sequences. */)
699 Lisp_Object x, y, window; 713 Lisp_Object x, y, window;
700 int keymaps = 0; 714 int keymaps = 0;
701 int for_click = 0; 715 int for_click = 0;
716 int specpdl_count = SPECPDL_INDEX ();
702 struct gcpro gcpro1; 717 struct gcpro gcpro1;
703 718
704#ifdef HAVE_MENUS 719#ifdef HAVE_MENUS
@@ -777,12 +792,11 @@ cached information about equivalent key sequences. */)
777 792
778 xpos += XINT (x); 793 xpos += XINT (x);
779 ypos += XINT (y); 794 ypos += XINT (y);
780
781 XSETFRAME (Vmenu_updating_frame, f);
782 } 795 }
783 Vmenu_updating_frame = Qnil; 796 Vmenu_updating_frame = Qnil;
784#endif /* HAVE_MENUS */ 797#endif /* HAVE_MENUS */
785 798
799 record_unwind_protect (unuse_menu_items, Qnil);
786 title = Qnil; 800 title = Qnil;
787 GCPRO1 (title); 801 GCPRO1 (title);
788 802
@@ -852,6 +866,8 @@ cached information about equivalent key sequences. */)
852 keymaps = 0; 866 keymaps = 0;
853 } 867 }
854 868
869 unbind_to (specpdl_count, Qnil);
870
855 if (NILP (position)) 871 if (NILP (position))
856 { 872 {
857 discard_menu_items (); 873 discard_menu_items ();
@@ -973,10 +989,12 @@ on the left of the dialog box and all following items on the right.
973 Lisp_Object title; 989 Lisp_Object title;
974 char *error_name; 990 char *error_name;
975 Lisp_Object selection; 991 Lisp_Object selection;
992 int specpdl_count = SPECPDL_INDEX ();
976 993
977 /* Decode the dialog items from what was specified. */ 994 /* Decode the dialog items from what was specified. */
978 title = Fcar (contents); 995 title = Fcar (contents);
979 CHECK_STRING (title); 996 CHECK_STRING (title);
997 record_unwind_protect (unuse_menu_items, Qnil);
980 998
981 list_of_panes (Fcons (contents, Qnil)); 999 list_of_panes (Fcons (contents, Qnil));
982 1000
@@ -985,6 +1003,7 @@ on the left of the dialog box and all following items on the right.
985 selection = xdialog_show (f, 0, title, &error_name); 1003 selection = xdialog_show (f, 0, title, &error_name);
986 UNBLOCK_INPUT; 1004 UNBLOCK_INPUT;
987 1005
1006 unbind_to (specpdl_count, Qnil);
988 discard_menu_items (); 1007 discard_menu_items ();
989 1008
990 if (error_name) error (error_name); 1009 if (error_name) error (error_name);
@@ -1126,7 +1145,7 @@ x_activate_menubar (f)
1126 1145
1127 set_frame_menubar (f, 0, 1); 1146 set_frame_menubar (f, 0, 1);
1128 BLOCK_INPUT; 1147 BLOCK_INPUT;
1129 XtDispatchEvent ((XEvent *) f->output_data.x->saved_menu_event); 1148 XtDispatchEvent (f->output_data.x->saved_menu_event);
1130 UNBLOCK_INPUT; 1149 UNBLOCK_INPUT;
1131#ifdef USE_MOTIF 1150#ifdef USE_MOTIF
1132 if (f->output_data.x->saved_menu_event->type == ButtonRelease) 1151 if (f->output_data.x->saved_menu_event->type == ButtonRelease)
@@ -1671,6 +1690,7 @@ set_frame_menubar (f, first_time, deep_p)
1671 specbind (Qdebug_on_next_call, Qnil); 1690 specbind (Qdebug_on_next_call, Qnil);
1672 1691
1673 record_unwind_protect (Fset_match_data, Fmatch_data (Qnil, Qnil)); 1692 record_unwind_protect (Fset_match_data, Fmatch_data (Qnil, Qnil));
1693 record_unwind_protect (unuse_menu_items, Qnil);
1674 if (NILP (Voverriding_local_map_menu_flag)) 1694 if (NILP (Voverriding_local_map_menu_flag))
1675 { 1695 {
1676 specbind (Qoverriding_terminal_local_map, Qnil); 1696 specbind (Qoverriding_terminal_local_map, Qnil);
@@ -1766,7 +1786,7 @@ set_frame_menubar (f, first_time, deep_p)
1766 if (i == menu_items_used && i == previous_menu_items_used && i != 0) 1786 if (i == menu_items_used && i == previous_menu_items_used && i != 0)
1767 { 1787 {
1768 free_menubar_widget_value_tree (first_wv); 1788 free_menubar_widget_value_tree (first_wv);
1769 menu_items = Qnil; 1789 discard_menu_items ();
1770 1790
1771 return; 1791 return;
1772 } 1792 }
@@ -1786,7 +1806,7 @@ set_frame_menubar (f, first_time, deep_p)
1786 1806
1787 f->menu_bar_vector = menu_items; 1807 f->menu_bar_vector = menu_items;
1788 f->menu_bar_items_used = menu_items_used; 1808 f->menu_bar_items_used = menu_items_used;
1789 menu_items = Qnil; 1809 discard_menu_items ();
1790 } 1810 }
1791 else 1811 else
1792 { 1812 {
@@ -2895,6 +2915,7 @@ syms_of_xmenu ()
2895{ 2915{
2896 staticpro (&menu_items); 2916 staticpro (&menu_items);
2897 menu_items = Qnil; 2917 menu_items = Qnil;
2918 menu_items_inuse = Qnil;
2898 2919
2899 Qdebug_on_next_call = intern ("debug-on-next-call"); 2920 Qdebug_on_next_call = intern ("debug-on-next-call");
2900 staticpro (&Qdebug_on_next_call); 2921 staticpro (&Qdebug_on_next_call);