; Move ns_init_colors from Fns_list_colors to emacs.c (bug#80377)

Support calls to ns_lisp_to_color or Fns_list_colors in headless
environments where ns_term_init is not called, and calls before
ns_term_init runs.

* src/emacs.c (main): Call ns_init_colors when not in dump mode.
* src/nsfns.m (ns_init_colors): Make public function.
(Fns_list_colors): Remove ns_init_colors call.
* src/nsterm.h: extern ns_init_colors.
This commit is contained in:
Stéphane Marks
2026-02-26 15:53:21 -05:00
committed by Alan Third
parent 64b0389a2c
commit b7aca342e6
3 changed files with 8 additions and 10 deletions

View File

@@ -2050,6 +2050,10 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
#endif
#ifdef HAVE_NS
/* For early calls to ns_lisp_to_color or Fns_list_colors. */
if (!dump_mode)
ns_init_colors ();
if (!noninteractive)
{
#ifdef NS_IMPL_COCOA

View File

@@ -2231,7 +2231,9 @@ font descriptor. If string contains `fontset' and not
return build_string (ns_xlfd_to_fontname (SSDATA (name)));
}
static void
/* Called in emacs.c to support early calls to ns_lisp_to_color or
Fns_list_colors. */
void
ns_init_colors (void)
{
NSTRACE ("ns_init_colors");
@@ -2286,8 +2288,6 @@ ns_init_colors (void)
}
}
static BOOL ns_init_colors_done = NO;
DEFUN ("ns-list-colors", Fns_list_colors, Sns_list_colors, 0, 1, 0,
doc: /* Return a list of all available colors.
The optional argument FRAME is currently ignored. */)
@@ -2298,12 +2298,6 @@ The optional argument FRAME is currently ignored. */)
NSColorList *clist;
NSAutoreleasePool *pool;
if (ns_init_colors_done == NO)
{
ns_init_colors ();
ns_init_colors_done = YES;
}
if (!NILP (frame))
{
CHECK_FRAME (frame);

View File

@@ -1150,6 +1150,7 @@ extern const char *ns_get_pending_menu_title (void);
#endif
/* Implemented in nsfns.m, published in nsterm.m. */
extern void ns_init_colors (void);
#ifdef __OBJC__
extern void ns_move_tooltip_to_mouse_location (NSPoint);
#endif
@@ -1161,7 +1162,6 @@ extern void ns_change_tab_bar_height (struct frame *f, int height);
extern const char *ns_get_string_resource (void *_rdb,
const char *name,
const char *class);
/* C access to ObjC functionality. */
extern void ns_release_object (void *obj);
extern void ns_retain_object (void *obj);