diff options
| author | Alan Third | 2021-01-05 21:43:12 +0000 |
|---|---|---|
| committer | Alan Third | 2021-01-05 21:43:12 +0000 |
| commit | 048b1aaec8d5cd4ce6e6a5a9b8091608d0af81a6 (patch) | |
| tree | 0552f38419dfc77dafb36c186902711ea878a8b2 /src | |
| parent | 3b835f7b81030f482348364e83f384a0fa4c2857 (diff) | |
| download | emacs-048b1aaec8d5cd4ce6e6a5a9b8091608d0af81a6.tar.gz emacs-048b1aaec8d5cd4ce6e6a5a9b8091608d0af81a6.zip | |
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')
| -rw-r--r-- | src/nsmenu.m | 21 |
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) | |||
| 145 | t = -(1000*tb.time+tb.millitm); | 145 | t = -(1000*tb.time+tb.millitm); |
| 146 | #endif | 146 | #endif |
| 147 | 147 | ||
| 148 | #ifdef NS_IMPL_GNUSTEP | ||
| 149 | deep_p = 1; /* See comment in menuNeedsUpdate. */ | ||
| 150 | #endif | ||
| 151 | |||
| 148 | if (deep_p) | 152 | if (deep_p) |
| 149 | { | 153 | { |
| 150 | /* Make a widget-value tree representing the entire menu trees. */ | 154 | /* 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) | |||
| 433 | } | 437 | } |
| 434 | 438 | ||
| 435 | 439 | ||
| 436 | /* Delegate method called when a submenu is being opened: run a 'deep' call | 440 | /* Delegate method called when a submenu is being opened: run a 'deep' |
| 437 | to set_frame_menubar. */ | 441 | call to ns_update_menubar. */ |
| 438 | |||
| 439 | /* TODO: GNUstep calls this method when the menu is still being built | ||
| 440 | which throws it into an infinite loop. One possible solution is to | ||
| 441 | use menuWillOpen instead, but the Apple docs explicitly warn | ||
| 442 | against changing the contents of the menu in it. I don't know what | ||
| 443 | the right thing to do for GNUstep is. */ | ||
| 444 | - (void)menuNeedsUpdate: (NSMenu *)menu | 442 | - (void)menuNeedsUpdate: (NSMenu *)menu |
| 445 | { | 443 | { |
| 446 | if (!FRAME_LIVE_P (SELECTED_FRAME ())) | 444 | if (!FRAME_LIVE_P (SELECTED_FRAME ())) |
| 447 | return; | 445 | return; |
| 448 | 446 | ||
| 447 | #ifdef NS_IMPL_COCOA | ||
| 448 | /* TODO: GNUstep calls this method when the menu is still being built | ||
| 449 | which results in a recursive stack overflow. One possible solution | ||
| 450 | is to use menuWillOpen instead, but the Apple docs explicitly warn | ||
| 451 | against changing the contents of the menu in it. I don't know what | ||
| 452 | the right thing to do for GNUstep is. */ | ||
| 449 | if (needsUpdate) | 453 | if (needsUpdate) |
| 450 | ns_update_menubar (SELECTED_FRAME (), true); | 454 | ns_update_menubar (SELECTED_FRAME (), true); |
| 455 | #endif | ||
| 451 | } | 456 | } |
| 452 | 457 | ||
| 453 | 458 | ||