On Mar 15, 2009, at 9:37 PM, YAMAMOTO Mitsuharu wrote: > [Revisiting an old change] > >>>>>> On Wed, 25 Apr 2007 20:30:08 +0200, Jan Djärv >>>>>> said: > >> After some experimenting it seems that this patch fixes it. Note >> that a call to redisplay() does not fix the bug. I don't know why. >> But a full redisplay before every dialog maybe is too much? > >> diff -w -c src/xmenu.c.~1.317.~ src/xmenu.c >> Index: src/xmenu.c >> *** src/xmenu.c.~1.317.~ 2007-01-21 11:33:57.000000000 +0100 >> --- src/xmenu.c 2007-04-25 20:27:02.000000000 +0200 >> *************** >> *** 3333,3338 **** >> --- 3333,3340 ---- >> /* No selection has been chosen yet. */ >> menu_item_selection = 0; > >> + Fredisplay (Qt); >> + >> /* Actually create and show the dialog. */ >> create_and_show_dialog (f, first_wv); > > Fredisplay runs timers and may cause string data relocation by GC. > Just before the call to Fredisplay, a widget value is created and it > points to some string data, which are to be used as button labels > after the Fredisplay call. So this may cause corruption of dialog > button labels. I've never seen such corruption actually, but I think > that may happen in principle unless I'm missing something. I absolutely see such corruption in the Carbon port, which creates the dialog in a similar fashion. This was in connection with a header line that uses an :eval expression, and a modified map-y-or-n-p that switches buffers to show the right one. As you say, the strings get destroyed, but that was relatively easy to fix by doing the redisplay a bit earlier. *** src/macmenu.c 30 Aug 2008 00:10:18 -0400 1.56.2.7 --- src/macmenu.c 09 Feb 2009 13:21:20 -0500 *************** *** 1882,1888 **** return Qnil; } ! /* Create a tree of widget_value objects representing the text label and buttons. */ { Lisp_Object pane_name, prefix; --- 1882,1893 ---- return Qnil; } ! /* Force a redisplay before showing the dialog. If a frame is created ! just before showing the dialog, its contents may not have been fully ! drawn. */ ! Fredisplay (Qt); ! ! /* Create a tree of widget_value objects representing the text label and buttons. */ { Lisp_Object pane_name, prefix; *************** *** 1985,1994 **** /* No selection has been chosen yet. */ menu_item_selection = 0; - /* Force a redisplay before showing the dialog. If a frame is created - just before showing the dialog, its contents may not have been fully - drawn. */ - Fredisplay (Qt); /* Actually create the dialog. */ #if TARGET_API_MAC_CARBON --- 1990,1995 ----