summaryrefslogtreecommitdiff
path: root/src/nsmenu.m
diff options
context:
space:
mode:
authorAlan Third <alan@idiocy.org>2021-01-05 21:43:12 +0000
committerAlan Third <alan@idiocy.org>2021-01-05 21:43:12 +0000
commit048b1aaec8d5cd4ce6e6a5a9b8091608d0af81a6 (patch)
tree0552f38419dfc77dafb36c186902711ea878a8b2 /src/nsmenu.m
parent3b835f7b81030f482348364e83f384a0fa4c2857 (diff)
downloademacs-048b1aaec8d5cd4ce6e6a5a9b8091608d0af81a6.tar.gz
Prevent stack overflow in GNUstep menu code
* src/nsmenu.m (ns_update_menubar): Always do a deep update for GNUstep. ([EmacsMenu menuNeedsUpdate:]): Don't update the menu as it should always have had a deep update.
Diffstat (limited to 'src/nsmenu.m')
-rw-r--r--src/nsmenu.m21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 9b56958100a..8086f56854e 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -145,6 +145,10 @@ ns_update_menubar (struct frame *f, bool deep_p)
t = -(1000*tb.time+tb.millitm);
#endif
+#ifdef NS_IMPL_GNUSTEP
+ deep_p = 1; /* See comment in menuNeedsUpdate. */
+#endif
+
if (deep_p)
{
/* Make a widget-value tree representing the entire menu trees. */
@@ -433,21 +437,22 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
}
-/* Delegate method called when a submenu is being opened: run a 'deep' call
- to set_frame_menubar. */
-
-/* TODO: GNUstep calls this method when the menu is still being built
- which throws it into an infinite loop. One possible solution is to
- use menuWillOpen instead, but the Apple docs explicitly warn
- against changing the contents of the menu in it. I don't know what
- the right thing to do for GNUstep is. */
+/* Delegate method called when a submenu is being opened: run a 'deep'
+ call to ns_update_menubar. */
- (void)menuNeedsUpdate: (NSMenu *)menu
{
if (!FRAME_LIVE_P (SELECTED_FRAME ()))
return;
+#ifdef NS_IMPL_COCOA
+/* TODO: GNUstep calls this method when the menu is still being built
+ which results in a recursive stack overflow. One possible solution
+ is to use menuWillOpen instead, but the Apple docs explicitly warn
+ against changing the contents of the menu in it. I don't know what
+ the right thing to do for GNUstep is. */
if (needsUpdate)
ns_update_menubar (SELECTED_FRAME (), true);
+#endif
}