summaryrefslogtreecommitdiff
path: root/src/xdisp.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2019-01-14 17:36:04 +0200
committerEli Zaretskii <eliz@gnu.org>2019-01-14 17:36:04 +0200
commit00ba2267ede311da0cd53261780fb0b781ca42dd (patch)
tree382b50db5ac01ecd7d3542b0e3e952c4b25f122b /src/xdisp.c
parentb26d6373c48ca26a7cfc81fd03ec8d7f50c13962 (diff)
downloademacs-00ba2267ede311da0cd53261780fb0b781ca42dd.tar.gz
Attempt to fix hangs on MS-Windows due to C-g
* src/w32uniscribe.c (uniscribe_otf_capability): Set inhibit-quit around calls to otf_features, because the latter cons Lisp data structures while we are in a critical section. * src/xdisp.c (ALLOCATE_HDC) [HAVE_NTGUI]: Set inhibit-quit. (RELEASE_HDC) [HAVE_NTGUI]: Restore inhibit-quit. (OPTIONAL_HDC, DECLARE_HDC): Remove macros, their job is now done by ALLOCATE_HDC and by a single #ifdef. (draw_glyphs): Adapt to the above changes in macros. (Bug#34059)
Diffstat (limited to 'src/xdisp.c')
-rw-r--r--src/xdisp.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 274ab8ddf51..94ce1c29a0c 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -25619,22 +25619,28 @@ dump_glyph_string (struct glyph_string *s)
face-override for drawing S. */
#ifdef HAVE_NTGUI
-#define OPTIONAL_HDC(hdc) HDC hdc,
-#define DECLARE_HDC(hdc) HDC hdc;
-#define ALLOCATE_HDC(hdc, f) hdc = get_frame_dc ((f))
-#define RELEASE_HDC(hdc, f) release_frame_dc ((f), (hdc))
-#endif
-
-#ifndef OPTIONAL_HDC
-#define OPTIONAL_HDC(hdc)
-#define DECLARE_HDC(hdc)
-#define ALLOCATE_HDC(hdc, f)
-#define RELEASE_HDC(hdc, f)
+/* We set inhibit-quit here due to paranoia: get_frame_dc acquires the
+ critical section, and we cannot QUIT while we hold the critical
+ section. If any of the code run by callers of ALLOCATE_HDC happens
+ to call Lisp (might be possible due to all the hooks lying around),
+ we must prevent it from quitting. */
+# define ALLOCATE_HDC(hdc, f) \
+ Lisp_Object prev_quit = Vinhibit_quit; \
+ Vinhibit_quit = Qt; \
+ HDC hdc = get_frame_dc ((f))
+# define RELEASE_HDC(hdc, f) \
+ release_frame_dc ((f), (hdc)); \
+ Vinhibit_quit = prev_quit
+#else
+# define ALLOCATE_HDC(hdc, f)
+# define RELEASE_HDC(hdc, f)
#endif
static void
init_glyph_string (struct glyph_string *s,
- OPTIONAL_HDC (hdc)
+#ifdef HAVE_NTGUI
+ HDC hdc,
+#endif
XChar2b *char2b, struct window *w, struct glyph_row *row,
enum glyph_row_area area, int start, enum draw_glyphs_face hl)
{
@@ -26674,7 +26680,6 @@ draw_glyphs (struct window *w, int x, struct glyph_row *row,
struct glyph_string *clip_head = NULL, *clip_tail = NULL;
int i, j, x_reached, last_x, area_left = 0;
struct frame *f = XFRAME (WINDOW_FRAME (w));
- DECLARE_HDC (hdc);
ALLOCATE_HDC (hdc, f);