[Top][All Lists]

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

[Emacs-diffs] emacs-26 00ba226: Attempt to fix hangs on MS-Windows due t

From: Eli Zaretskii
Subject: [Emacs-diffs] emacs-26 00ba226: Attempt to fix hangs on MS-Windows due to C-g
Date: Mon, 14 Jan 2019 10:37:45 -0500 (EST)

branch: emacs-26
commit 00ba2267ede311da0cd53261780fb0b781ca42dd
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    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.
 src/w32uniscribe.c |  6 ++++++
 src/xdisp.c        | 31 ++++++++++++++++++-------------
 2 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/src/w32uniscribe.c b/src/w32uniscribe.c
index 33959cd..28050d6 100644
--- a/src/w32uniscribe.c
+++ b/src/w32uniscribe.c
@@ -176,6 +176,11 @@ uniscribe_otf_capability (struct font *font)
   Lisp_Object features;
   f = XFRAME (selected_frame);
+  /* Prevent quitting while we cons the lists in otf_features.
+     That's because get_frame_dc acquires the critical section, so we
+     cannot quit before we release it in release_frame_dc.  */
+  Lisp_Object prev_quit = Vinhibit_quit;
+  Vinhibit_quit = Qt;
   context = get_frame_dc (f);
   old_font = SelectObject (context, FONT_HANDLE (font));
@@ -186,6 +191,7 @@ uniscribe_otf_capability (struct font *font)
   SelectObject (context, old_font);
   release_frame_dc (f, context);
+  Vinhibit_quit = prev_quit;
   return capability;
diff --git a/src/xdisp.c b/src/xdisp.c
index 274ab8d..94ce1c2 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))
-#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
+# define ALLOCATE_HDC(hdc, f)
+# define RELEASE_HDC(hdc, f)
 static void
 init_glyph_string (struct glyph_string *s,
-                  OPTIONAL_HDC (hdc)
+#ifdef HAVE_NTGUI
+                  HDC hdc,
                   XChar2b *char2b, struct window *w, struct glyph_row *row,
                   enum glyph_row_area area, int start, enum draw_glyphs_face 
@@ -26674,7 +26680,6 @@ draw_glyphs (struct window *w, int x, struct glyph_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);

reply via email to

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