diff options
author | Martin Rudalics <rudalics@gmx.at> | 2019-11-12 16:44:30 +0100 |
---|---|---|
committer | Martin Rudalics <rudalics@gmx.at> | 2019-11-12 16:44:30 +0100 |
commit | 1e5392a4ae710486f77afb5898c552b5b0e85061 (patch) | |
tree | 6a84983f3bd19f2c728cc8342b7c38d91dfda856 | |
parent | 6eaf62df205569f234160e7035dd7116af57810e (diff) | |
download | emacs-1e5392a4ae710486f77afb5898c552b5b0e85061.tar.gz |
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).
-rw-r--r-- | src/nsterm.m | 29 | ||||
-rw-r--r-- | src/w32term.c | 17 | ||||
-rw-r--r-- | src/window.h | 7 | ||||
-rw-r--r-- | src/xterm.c | 17 |
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, unsigned long descent = s->y + s->height - s->ybase; unsigned long minimum_offset; BOOL underline_at_descent_line, use_underline_position_properties; - Lisp_Object val = buffer_local_value (Qunderline_minimum_offset, - s->w->contents); - if (FIXNUMP (val)) - minimum_offset = XFIXNAT (val); - else - minimum_offset = 1; - val = buffer_local_value (Qx_underline_at_descent_line, - s->w->contents); - underline_at_descent_line = !(NILP (val) || EQ (val, Qunbound)); - val = buffer_local_value (Qx_use_underline_position_properties, - s->w->contents); - use_underline_position_properties = - !(NILP (val) || EQ (val, Qunbound)); + Lisp_Object val = (WINDOW_BUFFER_LOCAL_VALUE + (Qunderline_minimum_offset, s->w)); + + if (FIXNUMP (val)) + minimum_offset = XFIXNAT (val); + else + minimum_offset = 1; + + val = (WINDOW_BUFFER_LOCAL_VALUE + (Qx_underline_at_descent_line, s->w)); + underline_at_descent_line = !(NILP (val) || EQ (val, Qunbound)); + + val = (WINDOW_BUFFER_LOCAL_VALUE + (Qx_use_underline_position_properties, s->w)); + use_underline_position_properties + = !(NILP (val) || EQ (val, Qunbound)); /* Use underline thickness of font, defaulting to 1. */ 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) unsigned long minimum_offset; BOOL underline_at_descent_line; BOOL use_underline_position_properties; - Lisp_Object val - = buffer_local_value (Qunderline_minimum_offset, - s->w->contents); + Lisp_Object val = (WINDOW_BUFFER_LOCAL_VALUE + (Qunderline_minimum_offset, s->w)); + if (FIXNUMP (val)) minimum_offset = max (0, XFIXNUM (val)); else minimum_offset = 1; - val = buffer_local_value (Qx_underline_at_descent_line, - s->w->contents); + + val = (WINDOW_BUFFER_LOCAL_VALUE + (Qx_underline_at_descent_line, s->w)); underline_at_descent_line = !(NILP (val) || EQ (val, Qunbound)); - val - = buffer_local_value (Qx_use_underline_position_properties, - s->w->contents); + + val = (WINDOW_BUFFER_LOCAL_VALUE + (Qx_use_underline_position_properties, s->w)); use_underline_position_properties = !(NILP (val) || EQ (val, Qunbound)); 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) ? (W)->contents \ : Qnil) +/* Local value of variable V in window W's buffer. Nil if W has no + buffer. */ +#define WINDOW_BUFFER_LOCAL_VALUE(V, W) \ + (BUFFERP ((W)->contents) \ + ? buffer_local_value(V, (W)->contents) \ + : Qnil) + /* Return the canonical column width of the frame of window W. */ #define WINDOW_FRAME_COLUMN_WIDTH(W) \ (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) unsigned long minimum_offset; bool underline_at_descent_line; bool use_underline_position_properties; - Lisp_Object val - = buffer_local_value (Qunderline_minimum_offset, - s->w->contents); + Lisp_Object val = (WINDOW_BUFFER_LOCAL_VALUE + (Qunderline_minimum_offset, s->w)); + if (FIXNUMP (val)) minimum_offset = max (0, XFIXNUM (val)); else minimum_offset = 1; - val = buffer_local_value (Qx_underline_at_descent_line, - s->w->contents); + + val = (WINDOW_BUFFER_LOCAL_VALUE + (Qx_underline_at_descent_line, s->w)); underline_at_descent_line = !(NILP (val) || EQ (val, Qunbound)); - val - = buffer_local_value (Qx_use_underline_position_properties, - s->w->contents); + + val = (WINDOW_BUFFER_LOCAL_VALUE + (Qx_use_underline_position_properties, s->w)); use_underline_position_properties = !(NILP (val) || EQ (val, Qunbound)); |