Subject: bug#55068: 29.0.50; crashes when trying to set default font

From: Eli Zaretskii <[email-masked]>
Date: Mon, 23 May 2022 16:59:11 +0300

> From: Po Lu <[email-masked]>
> Cc: Eli Zaretskii <[email-masked]>,  [email-masked],  [email-masked]
> Date: Mon, 23 May 2022 20:40:02 +0800
> 
> Lars Ingebrigtsen <[email-masked]> writes:
> 
> > Nope; no crashes with that patch, thanks.
> >
> > (Side note: It is pretty slow, though -- popping up and closing the menu
> > both takes about five seconds on this laptop, so perhaps it should limit
> > the number of entries in one way or another.  And...  the family names
> > aren't sorted alphabetically?  And it looks like I'm getting several
> > instances of each family -- it's so slow that it's a bit painful to
> > scroll through, but I'm getting several instances of "Lato", for
> > instance, at arbitrary places in the list.)
> 
> Yes, I agree completely.  Allocating 20 MB to generate a popup menu also
> seems excessive, but we don't have a way of "lazy-loading" menus at
> present.
> 
> But for now let's just avoid the crash.  I will try to think up
> something later that doesn't involve selecting through many different
> layers of menus.

We have the same problem in other *menu.c files.  I fixed w32menu.c,
but there are pgtkmenu.c and nsmenu.m as well.

As for the rest: font-family-list is quite simple-minded, especially
if the frame has more than one font backend defined.  IME, to be
useful, its output should be run through delete-dups and then sorted.