emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master ea84a95: Check for GUI frame in ns_color_index_to_rgba


From: Robert Pluim
Subject: master ea84a95: Check for GUI frame in ns_color_index_to_rgba
Date: Wed, 11 Dec 2019 10:34:38 -0500 (EST)

branch: master
commit ea84a95bd8d43612b4a424fb93de25a68ac31d05
Author: Robert Pluim <address@hidden>
Commit: Robert Pluim <address@hidden>

    Check for GUI frame in ns_color_index_to_rgba
    
    * nsterm.m (ns_color_index_to_rgba): Check that we're using a GUI
    frame before converting color (Bug#38564).
---
 src/nsterm.m | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/nsterm.m b/src/nsterm.m
index c415159..6995577 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -2290,19 +2290,24 @@ ns_lisp_to_color (Lisp_Object color, NSColor **col)
 
 /* Convert an index into the color table into an RGBA value.  Used in
    xdisp.c:extend_face_to_end_of_line when comparing faces and frame
-   color values.  */
+   color values.  No-op on non-gui frames.  */
 
 unsigned long
 ns_color_index_to_rgba(int idx, struct frame *f)
 {
-  NSColor *col;
-  col = ns_lookup_indexed_color (idx, f);
+  if (FRAME_DISPLAY_INFO (f))
+    {
+      NSColor *col;
+      col = ns_lookup_indexed_color (idx, f);
 
-  EmacsCGFloat r, g, b, a;
-  [col getRed: &r green: &g blue: &b alpha: &a];
+      EmacsCGFloat r, g, b, a;
+      [col getRed: &r green: &g blue: &b alpha: &a];
 
-  return ARGB_TO_ULONG((int)(a*255),
-                       (int)(r*255), (int)(g*255), (int)(b*255));
+      return ARGB_TO_ULONG((int)(a*255),
+                           (int)(r*255), (int)(g*255), (int)(b*255));
+    }
+  else
+    return idx;
 }
 
 void



reply via email to

[Prev in Thread] Current Thread [Next in Thread]