comparison src/menubar-x.c @ 138:6608ceec7cf8 r20-2b3

Import from CVS: tag r20-2b3
author cvs
date Mon, 13 Aug 2007 09:31:46 +0200
parents 8619ce7e4c50
children 0132846995bd
comparison
equal deleted inserted replaced
137:cae984061f40 138:6608ceec7cf8
306 unbind_to (count, Qnil); 306 unbind_to (count, Qnil);
307 return wv; 307 return wv;
308 } 308 }
309 309
310 310
311 #ifdef LWLIB_MENUBARS_LUCID
312 int in_menu_callback;
313
314 Lisp_Object
315 restore_in_menu_callback(Lisp_Object val)
316 {
317 in_menu_callback = XINT(val);
318 return Qnil;
319 }
320 #endif /* LWLIB_MENUBARS_LUCID */
321
322
311 /* The order in which callbacks are run is funny to say the least. 323 /* The order in which callbacks are run is funny to say the least.
312 It's sometimes tricky to avoid running a callback twice, and to 324 It's sometimes tricky to avoid running a callback twice, and to
313 avoid returning prematurely. So, this function returns true 325 avoid returning prematurely. So, this function returns true
314 if the menu's callbacks are no longer gc protected. So long 326 if the menu's callbacks are no longer gc protected. So long
315 as we unprotect them before allowing other callbacks to run, 327 as we unprotect them before allowing other callbacks to run,
336 struct device *d = get_device_from_display (XtDisplay (widget)); 348 struct device *d = get_device_from_display (XtDisplay (widget));
337 struct frame *f = x_any_window_to_frame (d, XtWindow (widget)); 349 struct frame *f = x_any_window_to_frame (d, XtWindow (widget));
338 Lisp_Object rest = Qnil; 350 Lisp_Object rest = Qnil;
339 Lisp_Object frame; 351 Lisp_Object frame;
340 int any_changes = 0; 352 int any_changes = 0;
353 int count;
341 354
342 if (!f) 355 if (!f)
343 f = x_any_window_to_frame (d, XtWindow (XtParent (widget))); 356 f = x_any_window_to_frame (d, XtWindow (XtParent (widget)));
344 if (!f) 357 if (!f)
345 return; 358 return;
355 Lisp_Object submenu_desc; 368 Lisp_Object submenu_desc;
356 widget_value *wv; 369 widget_value *wv;
357 370
358 assert (hack_wv->type == INCREMENTAL_TYPE); 371 assert (hack_wv->type == INCREMENTAL_TYPE);
359 VOID_TO_LISP (submenu_desc, hack_wv->call_data); 372 VOID_TO_LISP (submenu_desc, hack_wv->call_data);
373
374 /*
375 * #### Fix the menu code so this isn't necessary.
376 *
377 * Protect against reentering the menu code otherwise we will
378 * crash later when the code gets confused at the state
379 * changes.
380 */
381 count = specpdl_depth ();
382 record_unwind_protect (restore_in_menu_callback,
383 make_int (in_menu_callback));
384 in_menu_callback = 1;
360 wv = menu_item_descriptor_to_widget_value (submenu_desc, SUBMENU_TYPE, 385 wv = menu_item_descriptor_to_widget_value (submenu_desc, SUBMENU_TYPE,
361 1, 0); 386 1, 0);
387 unbind_to (count, Qnil);
388
362 if (!wv) 389 if (!wv)
363 { 390 {
364 wv = xmalloc_widget_value (); 391 wv = xmalloc_widget_value ();
365 wv->type = CASCADE_TYPE; 392 wv->type = CASCADE_TYPE;
366 wv->next = NULL; 393 wv->next = NULL;