aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Rudalics2019-11-12 16:44:30 +0100
committerMartin Rudalics2019-11-12 16:44:30 +0100
commit1e5392a4ae710486f77afb5898c552b5b0e85061 (patch)
tree6a84983f3bd19f2c728cc8342b7c38d91dfda856 /src
parent6eaf62df205569f234160e7035dd7116af57810e (diff)
downloademacs-1e5392a4ae710486f77afb5898c552b5b0e85061.tar.gz
emacs-1e5392a4ae710486f77afb5898c552b5b0e85061.zip
Make sure buffer is live before retrieving underline properties (Bug#38038)
* src/window.h (WINDOW_BUFFER_LOCAL_VALUE): New macro. * src/nsterm.m (ns_draw_text_decoration): * src/w32term.c (w32_draw_glyph_string): * src/xterm.c (x_draw_glyph_string): Make sure buffer is live before retrieving underline properties from it (Bug#38038).
Diffstat (limited to 'src')
-rw-r--r--src/nsterm.m29
-rw-r--r--src/w32term.c17
-rw-r--r--src/window.h7
-rw-r--r--src/xterm.c17
4 files changed, 41 insertions, 29 deletions
diff --git a/src/nsterm.m b/src/nsterm.m
index 9d5082b71df..e1d745e332d 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -3435,19 +3435,22 @@ ns_draw_text_decoration (struct glyph_string *s, struct face *face,
3435 unsigned long descent = s->y + s->height - s->ybase; 3435 unsigned long descent = s->y + s->height - s->ybase;
3436 unsigned long minimum_offset; 3436 unsigned long minimum_offset;
3437 BOOL underline_at_descent_line, use_underline_position_properties; 3437 BOOL underline_at_descent_line, use_underline_position_properties;
3438 Lisp_Object val = buffer_local_value (Qunderline_minimum_offset, 3438 Lisp_Object val = (WINDOW_BUFFER_LOCAL_VALUE
3439 s->w->contents); 3439 (Qunderline_minimum_offset, s->w));
3440 if (FIXNUMP (val)) 3440
3441 minimum_offset = XFIXNAT (val); 3441 if (FIXNUMP (val))
3442 else 3442 minimum_offset = XFIXNAT (val);
3443 minimum_offset = 1; 3443 else
3444 val = buffer_local_value (Qx_underline_at_descent_line, 3444 minimum_offset = 1;
3445 s->w->contents); 3445
3446 underline_at_descent_line = !(NILP (val) || EQ (val, Qunbound)); 3446 val = (WINDOW_BUFFER_LOCAL_VALUE
3447 val = buffer_local_value (Qx_use_underline_position_properties, 3447 (Qx_underline_at_descent_line, s->w));
3448 s->w->contents); 3448 underline_at_descent_line = !(NILP (val) || EQ (val, Qunbound));
3449 use_underline_position_properties = 3449
3450 !(NILP (val) || EQ (val, Qunbound)); 3450 val = (WINDOW_BUFFER_LOCAL_VALUE
3451 (Qx_use_underline_position_properties, s->w));
3452 use_underline_position_properties
3453 = !(NILP (val) || EQ (val, Qunbound));
3451 3454
3452 /* Use underline thickness of font, defaulting to 1. */ 3455 /* Use underline thickness of font, defaulting to 1. */
3453 thickness = (font && font->underline_thickness > 0) 3456 thickness = (font && font->underline_thickness > 0)
diff --git a/src/w32term.c b/src/w32term.c
index 9da0845836a..d0537c67e9a 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -2512,20 +2512,21 @@ w32_draw_glyph_string (struct glyph_string *s)
2512 unsigned long minimum_offset; 2512 unsigned long minimum_offset;
2513 BOOL underline_at_descent_line; 2513 BOOL underline_at_descent_line;
2514 BOOL use_underline_position_properties; 2514 BOOL use_underline_position_properties;
2515 Lisp_Object val 2515 Lisp_Object val = (WINDOW_BUFFER_LOCAL_VALUE
2516 = buffer_local_value (Qunderline_minimum_offset, 2516 (Qunderline_minimum_offset, s->w));
2517 s->w->contents); 2517
2518 if (FIXNUMP (val)) 2518 if (FIXNUMP (val))
2519 minimum_offset = max (0, XFIXNUM (val)); 2519 minimum_offset = max (0, XFIXNUM (val));
2520 else 2520 else
2521 minimum_offset = 1; 2521 minimum_offset = 1;
2522 val = buffer_local_value (Qx_underline_at_descent_line, 2522
2523 s->w->contents); 2523 val = (WINDOW_BUFFER_LOCAL_VALUE
2524 (Qx_underline_at_descent_line, s->w));
2524 underline_at_descent_line 2525 underline_at_descent_line
2525 = !(NILP (val) || EQ (val, Qunbound)); 2526 = !(NILP (val) || EQ (val, Qunbound));
2526 val 2527
2527 = buffer_local_value (Qx_use_underline_position_properties, 2528 val = (WINDOW_BUFFER_LOCAL_VALUE
2528 s->w->contents); 2529 (Qx_use_underline_position_properties, s->w));
2529 use_underline_position_properties 2530 use_underline_position_properties
2530 = !(NILP (val) || EQ (val, Qunbound)); 2531 = !(NILP (val) || EQ (val, Qunbound));
2531 2532
diff --git a/src/window.h b/src/window.h
index 71946a56955..5b9a3140c8f 100644
--- a/src/window.h
+++ b/src/window.h
@@ -608,6 +608,13 @@ wset_next_buffers (struct window *w, Lisp_Object val)
608 ? (W)->contents \ 608 ? (W)->contents \
609 : Qnil) 609 : Qnil)
610 610
611/* Local value of variable V in window W's buffer. Nil if W has no
612 buffer. */
613#define WINDOW_BUFFER_LOCAL_VALUE(V, W) \
614 (BUFFERP ((W)->contents) \
615 ? buffer_local_value(V, (W)->contents) \
616 : Qnil)
617
611/* Return the canonical column width of the frame of window W. */ 618/* Return the canonical column width of the frame of window W. */
612#define WINDOW_FRAME_COLUMN_WIDTH(W) \ 619#define WINDOW_FRAME_COLUMN_WIDTH(W) \
613 (FRAME_COLUMN_WIDTH (WINDOW_XFRAME ((W)))) 620 (FRAME_COLUMN_WIDTH (WINDOW_XFRAME ((W))))
diff --git a/src/xterm.c b/src/xterm.c
index 44fbd27b11a..f7005804f02 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -3847,20 +3847,21 @@ x_draw_glyph_string (struct glyph_string *s)
3847 unsigned long minimum_offset; 3847 unsigned long minimum_offset;
3848 bool underline_at_descent_line; 3848 bool underline_at_descent_line;
3849 bool use_underline_position_properties; 3849 bool use_underline_position_properties;
3850 Lisp_Object val 3850 Lisp_Object val = (WINDOW_BUFFER_LOCAL_VALUE
3851 = buffer_local_value (Qunderline_minimum_offset, 3851 (Qunderline_minimum_offset, s->w));
3852 s->w->contents); 3852
3853 if (FIXNUMP (val)) 3853 if (FIXNUMP (val))
3854 minimum_offset = max (0, XFIXNUM (val)); 3854 minimum_offset = max (0, XFIXNUM (val));
3855 else 3855 else
3856 minimum_offset = 1; 3856 minimum_offset = 1;
3857 val = buffer_local_value (Qx_underline_at_descent_line, 3857
3858 s->w->contents); 3858 val = (WINDOW_BUFFER_LOCAL_VALUE
3859 (Qx_underline_at_descent_line, s->w));
3859 underline_at_descent_line 3860 underline_at_descent_line
3860 = !(NILP (val) || EQ (val, Qunbound)); 3861 = !(NILP (val) || EQ (val, Qunbound));
3861 val 3862
3862 = buffer_local_value (Qx_use_underline_position_properties, 3863 val = (WINDOW_BUFFER_LOCAL_VALUE
3863 s->w->contents); 3864 (Qx_use_underline_position_properties, s->w));
3864 use_underline_position_properties 3865 use_underline_position_properties
3865 = !(NILP (val) || EQ (val, Qunbound)); 3866 = !(NILP (val) || EQ (val, Qunbound));
3866 3867