From: Alan Third <alan@idiocy.org>
To: "Daniel Martín" <mardani29@yahoo.es>
Cc: 63495@debbugs.gnu.org, obriendavid1@gmail.com, me@eshelyaron.com
Subject: bug#63495: 28.2; menu crashes on macos
Date: Tue, 25 Jul 2023 17:16:17 +0100 [thread overview]
Message-ID: <ZL/1Ub771U4N5MiA@idiocy.org> (raw)
In-Reply-To: <m1y1jkfba0.fsf@yahoo.es>
On Thu, Jul 13, 2023 at 10:47:35AM +0200, Daniel Martín wrote:
> One fundamental problem I see with the current logic (or maybe I'm
> misunderstanding something) is that, menuNeedsUpdate: is called for both
> the menubar and for context menus. However, the ns_update_menubar
> routine does not even use the NSMenu that AppKit passed to
> menuNeedsUpdate:, it always does this:
>
> id menu = [NSApp mainMenu];
>
> This means that the menu variable will always be the menubar. The code
> in ns_update_menubar is only prepared to handle menubar updates, but as
> this function updates menu_items, a data structure that is used later by
> the context menu in find_and_return_menu_selection, Emacs crashes
> because of inconsistencies.
>
> Is there any reason we need to do something for context menus in
> menuNeedsUpdate:? Alan said that context menus are completely built in
> advance (as opposed to the menubar, which is partially built), so I
> propose the following patch (which does seem to fix the crash for me and
> doesn't cause regressions with the menubar):
>
> diff --git a/src/nsmenu.m b/src/nsmenu.m
> index 2c1f575bdf2..ca367d1abd1 100644
> --- a/src/nsmenu.m
> +++ b/src/nsmenu.m
> @@ -477,6 +477,16 @@ - (instancetype)initWithTitle: (NSString *)title
> call to ns_update_menubar. */
> - (void)menuNeedsUpdate: (NSMenu *)menu
> {
> +
> + /* The context menu is built and then displayed, as opposed to the
> + top-menu, which is partially built and then updated and filled in
> + when it's time to display it. Therefore, we don't call
> + ns_update_menubar if a context menu is active. */
> + if (context_menu_value != 0)
> + {
> + return;
> + }
> +
> #ifdef NS_IMPL_GNUSTEP
> static int inside = 0;
> #endif
If it hasn't already, this should probably be pushed into the emacs-29
branch, unless someone's noticed a problem with it, as I understand
the first(?) rc has already been released.
This fixes a crash.
Eli/Lars? Is it too late?
--
Alan Third
next prev parent reply other threads:[~2023-07-25 16:16 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-13 15:36 bug#63495: 28.2; menu crashes on macos David O'Brien
2023-05-14 9:18 ` Eli Zaretskii
2023-07-08 18:18 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-09 7:29 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-10 21:00 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-10 22:33 ` Alan Third
2023-07-11 5:40 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-12 17:25 ` Alan Third
2023-07-12 17:44 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-12 19:37 ` Alan Third
2023-07-13 6:16 ` Eshel Yaron via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-13 8:47 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-07-13 19:41 ` Alan Third
2023-07-25 16:16 ` Alan Third [this message]
2023-07-25 17:47 ` Eli Zaretskii
2023-09-06 20:16 ` Stefan Kangas
2023-09-06 20:29 ` Alan Third
2023-09-06 22:34 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-09-07 5:23 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZL/1Ub771U4N5MiA@idiocy.org \
--to=alan@idiocy.org \
--cc=63495@debbugs.gnu.org \
--cc=mardani29@yahoo.es \
--cc=me@eshelyaron.com \
--cc=obriendavid1@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).