Subject: 24.0.50; ns menus are all blank

From: Derrell Piper <[email-masked]>
Date: Mon, 13 Sep 2010 12:25:05 -0700

[10.6.4, Xcode 3.2.4, MacOSX10.6.sdk]

Somewhere along the line, the version of 23.1 I had built for Snow
Leopard started showing me blank menus for everything.  The menu items
are present in the menu bar, but all blank.  If you click enough on a
menu item, you can usually get it to appear.  Once it does appear, it
stays for a while, but can go away later.

So I upgraded to the current trunk from bazaar and the problem's still
happening there too.  Imperically, the following patch to nsmenu.m seems
to fix this problem:

=== modified file 'src/nsmenu.m'
--- src/nsmenu.m	2010-08-11 12:34:46 +0000
+++ src/nsmenu.m	2010-09-13 19:04:37 +0000
@@ -568,18 +568,14 @@
   NSEvent *event;
   if (!FRAME_LIVE_P (frame))
     return;
+  /* Don't try this if from an event picked up asynchronously,
+     as lots of lisp evaluation happens in ns_update_menubar. */
+  if (handling_signal != 0)
+    return;
   event = [[FRAME_NS_VIEW (frame) window] currentEvent];
-  /* HACK: Cocoa/Carbon will request update on every keystroke
-     via IsMenuKeyEvent -> CheckMenusForKeyEvent.  These are not needed
-     since key equivalents are handled through emacs.
-     On Leopard, even keystroke events generate SystemDefined events, but
-     their subtype is 8. */
-  if ([event type] != NSSystemDefined || [event subtype] == 8
-      /* Also, don't try this if from an event picked up asynchronously,
-         as lots of lisp evaluation happens in ns_update_menubar. */
-      || handling_signal != 0)
-    return;
/*fprintf (stderr, "Updating menu '%s'\n", [[self title] UTF8String]); NSLog (@"%@\n", event); */
+  if ([event type] != NSApplicationDefined)
+    return;
   ns_update_menubar (frame, 1, self);
}

...however, I'm not familiar enough with this code (or with NSEvent) to
be sure that this fix is the correct one.  With this patch, the menus
all function and nothing untoward is getting logged to /var/log/system.

I have not tested this on prior versions of OS X, nor on GNUstep.

In GNU Emacs 24.0.50.14 (x86_64-apple-darwin10.4.0, NS apple-appkit-1038.32)
of 2010-09-13 on fluffy.local
Windowing system distributor `Apple', version 10.3.1038
configured using `configure  '--with-ns''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: ObjC/l

Minor modes in effect:
  tooltip-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  abbrev-mode: t

Recent input:
<backspace> <backspace> i s SPC a SPC v e r s i o n 
SPC b u i l t SPC w i t h SPC <backspace> <backspace> 
<backspace> <backspace> <backspace> <backspace> <backspace> 
<backspace> <backspace> <backspace> <backspace> <backspace> 
<backspace> <backspace> <backspace> <backspace> <backspace> 
<backspace> <backspace> <backspace> <backspace> <backspace> 
<backspace> <backspace> <backspace> <backspace> <backspace> 
<backspace> <backspace> <backspace> <backspace> C-p 
C-a C-o s-v <backspace> <backspace> C-a C-d [ C-e [ 
<backspace> ] <return> C-n C-n C-p C-f C-f C-f C-f 
C-f C-f C-f C-f C-f C-f C-f C-f C-f C-f C-f C-f C-f 
C-f C-f C-f C-f C-f C-f C-f C-f C-f C-f C-f C-f C-f 
C-f C-f C-f C-f C-f C-f C-f C-f C-b C-b C-b C-b C-b 
C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b C-b 
C-b C-b C-j C-j C-j C-j ESC q C-n C-e SPC SPC I t ' 
s SPC p r e s e n t SPC i n SPC t h e SPC a p p p <backspace> 
l i c a t i o n SPC m e n u S-SPC ( " E m a <backspace> 
<backspace> <backspace> <backspace> <backspace> b u 
t SPC <backspace> <backspace> <backspace> <backspace> 
a s SPC a SPC h e i r a r <backspace> <backspace> <backspace> 
<backspace> <backspace> <backspace> <backspace> <backspace> 
<backspace> <backspace> <backspace> b u t SPC <backspace> 
<backspace> <backspace> <backspace> <backspace> , SPC 
b u t SPC b l a n k . C-p C-n C-c C-c y C-p C-p C-p 
C-n C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p 
C-p C-p C-a C-SPC C-n C-n C-n C-n C-n C-n C-n C-n C-n 
C-n C-n C-n C-n C-n C-n C-n <down-mouse-1> <mouse-1> 
M-x r e p r o t <backspace> <backspace> <backspace> 
o r t <tab> <return>

Recent messages:
Auto-saving...done
Mark set
No closing parenthesis found
Auto-saving...done
Send this bug report to the Emacs maintainers?  y
Sending...
Sending via mail...
Sending...done
Unable to load color "dark cyan"
Mark set

Load-path shadows:
~/src/el/custom hides /Users/ddp/src/trunk/nextstep/Emacs.app/Contents/Resources/lisp/custom
~/src/el/xscheme hides /Users/ddp/src/trunk/nextstep/Emacs.app/Contents/Resources/lisp/progmodes/xscheme
/Users/ddp/src/trunk/nextstep/Emacs.app/Contents/Resources/lisp/progmodes/cc-vars hides /Users/ddp/src/el/cc-mode-5.31.3/cc-vars
/Users/ddp/src/trunk/nextstep/Emacs.app/Contents/Resources/lisp/progmodes/cc-styles hides /Users/ddp/src/el/cc-mode-5.31.3/cc-styles
/Users/ddp/src/trunk/nextstep/Emacs.app/Contents/Resources/lisp/progmodes/cc-mode hides /Users/ddp/src/el/cc-mode-5.31.3/cc-mode
/Users/ddp/src/trunk/nextstep/Emacs.app/Contents/Resources/lisp/progmodes/cc-menus hides /Users/ddp/src/el/cc-mode-5.31.3/cc-menus
/Users/ddp/src/trunk/nextstep/Emacs.app/Contents/Resources/lisp/progmodes/cc-langs hides /Users/ddp/src/el/cc-mode-5.31.3/cc-langs
/Users/ddp/src/trunk/nextstep/Emacs.app/Contents/Resources/lisp/progmodes/cc-fonts hides /Users/ddp/src/el/cc-mode-5.31.3/cc-fonts
/Users/ddp/src/trunk/nextstep/Emacs.app/Contents/Resources/lisp/progmodes/cc-engine hides /Users/ddp/src/el/cc-mode-5.31.3/cc-engine
/Users/ddp/src/trunk/nextstep/Emacs.app/Contents/Resources/lisp/progmodes/cc-defs hides /Users/ddp/src/el/cc-mode-5.31.3/cc-defs
/Users/ddp/src/trunk/nextstep/Emacs.app/Contents/Resources/lisp/progmodes/cc-compat hides /Users/ddp/src/el/cc-mode-5.31.3/cc-compat
/Users/ddp/src/trunk/nextstep/Emacs.app/Contents/Resources/lisp/progmodes/cc-cmds hides /Users/ddp/src/el/cc-mode-5.31.3/cc-cmds
/Users/ddp/src/trunk/nextstep/Emacs.app/Contents/Resources/lisp/progmodes/cc-bytecomp hides /Users/ddp/src/el/cc-mode-5.31.3/cc-bytecomp
/Users/ddp/src/trunk/nextstep/Emacs.app/Contents/Resources/lisp/progmodes/cc-awk hides /Users/ddp/src/el/cc-mode-5.31.3/cc-awk
/Users/ddp/src/trunk/nextstep/Emacs.app/Contents/Resources/lisp/progmodes/cc-align hides /Users/ddp/src/el/cc-mode-5.31.3/cc-align

Features:
(browse-url mailalias mailclient sendmail newcomment help-mode view
shadow sort gnus-util mail-extr message rfc822 mml mml-sec mm-decode
mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mailabbrev mail-utils gmm-utils mailheader emacsbug
vc-git ebuff-menu electric multi-isearch vc-bzr sha1 hex-util cc-mode
cc-fonts cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
regexp-opt finder-inf package simple-wiki derived scheme-complete
git-blame git log-edit easy-mmode ring pcvs-util ewoc add-log avoid
server paren mic-paren cl cl-19 tooltip ediff-hook vc-hooks
lisp-float-type mwheel ns-win easymenu tool-bar dnd fontset image fringe
lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar
mldrag mouse jit-lock font-lock syntax facemenu font-core frame cham
georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese hebrew greek romanian slovak czech european ethiopic
indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple
abbrev loaddefs button minibuffer faces cus-face files text-properties
overlay md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process ns multi-tty
emacs)