1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2025-01-16 17:19:41 +00:00

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)
This commit is contained in:
Eli Zaretskii 2019-01-14 17:36:04 +02:00
parent b26d6373c4
commit 00ba2267ed
2 changed files with 24 additions and 13 deletions

View File

@ -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;
}

View File

@ -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);