Subject: Re: bug#38564: 27.0.50; macOS "emacs -nw" git-gutter-mode segfault

From: Robert Pluim <[email-masked]>
Date: Thu, 12 Dec 2019 08:45:11 +0100

>>>>> On Wed, 11 Dec 2019 19:37:34 +0000, Alan Third <[email-masked]> said:

    Alan> On Wed, Dec 11, 2019 at 11:12:41AM +0100, Robert Pluim wrote:
    >> Right idea, but one layer lower than needed. ns_color_index_to_rgba
    >> should not be calling ns_lookup_indexed_color in non-gui mode. Try
    >> this instead:

    Alan> Hi Robert, thanks for sorting this. One thing...

    >> +  if (FRAME_DISPLAY_INFO (f))

    Alan> Would it not be better to use FRAME_NS_P?

Yes. In fact, how about reverting my change to ns_color_index_to_rgba
and doing this instead (you canʼt use FRAME_DISPLAY_INFO in
dispextern.h without much bigger changes):

diff --git i/src/dispextern.h w/src/dispextern.h
index 0615b16d71..4bf9f39cd0 100644
--- i/src/dispextern.h
+++ w/src/dispextern.h
@@ -123,7 +123,9 @@ #define NativeRectangle XRectangle

 #ifdef HAVE_NS
 #include "nsgui.h"
-#define FACE_COLOR_TO_PIXEL(face_color, frame) ns_color_index_to_rgba(face_color, frame)
+#define FACE_COLOR_TO_PIXEL(face_color, frame) (FRAME_NS_P (frame) \
+                                                ? ns_color_index_to_rgba (face_color, frame) \
+                                                : face_color)
 /* Following typedef needed to accommodate the MSDOS port, believe it or not.  */
 typedef struct ns_display_info Display_Info;
 typedef Emacs_Pixmap Emacs_Pix_Container;