Mercurial > hg > xemacs-beta
comparison 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 |
comparison
equal
deleted
inserted
replaced
1917:a84a8743f195 | 1918:59bf16be00bf |
---|---|
334 | 334 |
335 unbind_to (count); | 335 unbind_to (count); |
336 return wv; | 336 return wv; |
337 } | 337 } |
338 | 338 |
339 struct menu_item_descriptor_to_widget_value | |
340 { | |
341 Lisp_Object desc; | |
342 int menu_type, deep_p, filter_p; | |
343 widget_value *wv; | |
344 }; | |
345 | |
346 static Lisp_Object | |
347 protected_menu_item_descriptor_to_widget_value_1 (void *gack) | |
348 { | |
349 struct menu_item_descriptor_to_widget_value *midtwv = | |
350 (struct menu_item_descriptor_to_widget_value *) gack; | |
351 int count = begin_gc_forbidden (); | |
352 /* Can't GC! */ | |
353 midtwv->wv = menu_item_descriptor_to_widget_value_1 (midtwv->desc, | |
354 midtwv->menu_type, | |
355 midtwv->deep_p, | |
356 midtwv->filter_p, | |
357 0); | |
358 unbind_to (count); | |
359 return Qnil; | |
360 } | |
361 | |
362 /* Inside of the pre_activate_callback, we absolutely need to protect | |
363 against errors, esp. but not exclusively in the filter code. (We do | |
364 other evalling, too.) We also need to reenable quit checking, which | |
365 was disabled by next_event_internal() so as to read C-g as an | |
366 event. */ | |
367 | |
368 static widget_value * | |
369 protected_menu_item_descriptor_to_widget_value (Lisp_Object desc, | |
370 int menu_type, int deep_p, | |
371 int filter_p) | |
372 { | |
373 struct menu_item_descriptor_to_widget_value midtwv; | |
374 int depth = internal_bind_int (&in_menu_callback, 1); | |
375 Lisp_Object retval; | |
376 | |
377 midtwv.desc = desc; | |
378 midtwv.menu_type = menu_type; | |
379 midtwv.deep_p = deep_p; | |
380 midtwv.filter_p = filter_p; | |
381 | |
382 retval = event_stream_protect_modal_loop | |
383 ("Error during menu callback", | |
384 protected_menu_item_descriptor_to_widget_value_1, &midtwv, | |
385 UNINHIBIT_QUIT); | |
386 unbind_to (depth); | |
387 | |
388 if (UNBOUNDP (retval)) | |
389 return 0; | |
390 | |
391 return midtwv.wv; | |
392 } | |
393 | |
394 /* The two callers of menu_item_descriptor_to_widget_value may both run while | |
395 in redisplay. Some descriptor to widget value conversions call Feval, and | |
396 at least one calls QUIT. Hence, we have to establish protection here.. */ | |
397 | |
339 static widget_value * | 398 static widget_value * |
340 menu_item_descriptor_to_widget_value (Lisp_Object desc, | 399 menu_item_descriptor_to_widget_value (Lisp_Object desc, |
341 int menu_type, /* if this is a menubar, | 400 int menu_type, /* if this is a menubar, |
342 popup or sub menu */ | 401 popup or sub menu */ |
343 int deep_p, /* */ | 402 int deep_p, /* */ |
344 int filter_p) /* if :filter forms | 403 int filter_p) /* if :filter forms |
345 should run now */ | 404 should run now */ |
346 { | 405 { |
347 widget_value *wv; | |
348 int count = begin_gc_forbidden (); | |
349 /* Can't GC! */ | |
350 wv = menu_item_descriptor_to_widget_value_1 (desc, menu_type, deep_p, | |
351 filter_p, 0); | |
352 unbind_to (count); | |
353 return wv; | |
354 } | |
355 | |
356 struct menu_item_descriptor_to_widget_value | |
357 { | |
358 Lisp_Object desc; | |
359 int menu_type, deep_p, filter_p; | |
360 widget_value *wv; | |
361 }; | |
362 | |
363 static Lisp_Object | |
364 protected_menu_item_descriptor_to_widget_value_1 (void *gack) | |
365 { | |
366 struct menu_item_descriptor_to_widget_value *midtwv = | |
367 (struct menu_item_descriptor_to_widget_value *) gack; | |
368 | |
369 midtwv->wv = menu_item_descriptor_to_widget_value (midtwv->desc, | |
370 midtwv->menu_type, | |
371 midtwv->deep_p, | |
372 midtwv->filter_p); | |
373 return Qnil; | |
374 } | |
375 | |
376 /* Inside of the pre_activate_callback, we absolutely need to protect | |
377 against errors, esp. but not exclusively in the filter code. (We do | |
378 other evalling, too.) We also need to reenable quit checking, which | |
379 was disabled by next_event_internal() so as to read C-g as an | |
380 event. */ | |
381 | |
382 static widget_value * | |
383 protected_menu_item_descriptor_to_widget_value (Lisp_Object desc, | |
384 int menu_type, int deep_p, | |
385 int filter_p) | |
386 { | |
387 struct menu_item_descriptor_to_widget_value midtwv; | 406 struct menu_item_descriptor_to_widget_value midtwv; |
388 int depth = internal_bind_int (&in_menu_callback, 1); | |
389 Lisp_Object retval; | 407 Lisp_Object retval; |
390 | 408 |
391 midtwv.desc = desc; | 409 midtwv.desc = desc; |
392 midtwv.menu_type = menu_type; | 410 midtwv.menu_type = menu_type; |
393 midtwv.deep_p = deep_p; | 411 midtwv.deep_p = deep_p; |
394 midtwv.filter_p = filter_p; | 412 midtwv.filter_p = filter_p; |
395 | 413 |
396 retval = event_stream_protect_modal_loop | 414 retval = call_trapping_problems |
397 ("Error during menu callback", | 415 (Qevent, "Error during menu construction", 0, NULL, |
398 protected_menu_item_descriptor_to_widget_value_1, &midtwv, | 416 protected_menu_item_descriptor_to_widget_value_1, &midtwv); |
399 UNINHIBIT_QUIT); | |
400 unbind_to (depth); | |
401 | 417 |
402 if (UNBOUNDP (retval)) | 418 if (UNBOUNDP (retval)) |
403 return 0; | 419 return NULL; |
404 | 420 |
405 return midtwv.wv; | 421 return midtwv.wv; |
406 } | 422 } |
407 | 423 |
408 /* The order in which callbacks are run is funny to say the least. | 424 /* The order in which callbacks are run is funny to say the least. |