[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 18868de463 1/2: Merge from origin/emacs-28
From: |
Po Lu |
Subject: |
master 18868de463 1/2: Merge from origin/emacs-28 |
Date: |
Thu, 3 Mar 2022 20:02:04 -0500 (EST) |
branch: master
commit 18868de46340ce8a1b2c2a1d9d81364530509e98
Merge: aeb25f9d3d 29ff903bb0
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
Merge from origin/emacs-28
29ff903bb0 Avoid crashes when fringe bitmaps are defined in daemon mode
92e2d19fe7 One more fix of the BPA implementation
cd51d9c7ab Fix handling of brackets in BPA
---
src/bidi.c | 5 ++++-
src/dispextern.h | 3 +++
src/fringe.c | 17 +++++++++++++++++
src/w32term.c | 15 ++++++++++++++-
src/xterm.c | 14 +++++++++++++-
5 files changed, 51 insertions(+), 3 deletions(-)
diff --git a/src/bidi.c b/src/bidi.c
index 16faf655b2..dfe21c86d6 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -2758,6 +2758,7 @@ bidi_find_bracket_pairs (struct bidi_it *bidi_it)
(which requires the display engine to copy the cache back and
forth many times). */
if (maxlevel == base_level
+ && (l2r_seen || r2l_seen) /* N0d */
&& ((base_level == 0 && !r2l_seen)
|| (base_level == 1 && !l2r_seen)))
{
@@ -2924,7 +2925,8 @@ bidi_resolve_brackets (struct bidi_it *bidi_it)
eassert (bidi_it->bracket_pairing_pos > bidi_it->charpos);
if (bidi_it->bracket_enclosed_type == embedding_type) /* N0b */
type = embedding_type;
- else
+ else if (bidi_it->bracket_enclosed_type == STRONG_L /* N0c, N0d */
+ || bidi_it->bracket_enclosed_type == STRONG_R)
{
switch (bidi_it->prev_for_neutral.type)
{
@@ -2944,6 +2946,7 @@ bidi_resolve_brackets (struct bidi_it *bidi_it)
break;
default:
/* N0d: Do not set the type for that bracket pair. */
+ /* (Actuallly, this shouldn't happen.) */
break;
}
}
diff --git a/src/dispextern.h b/src/dispextern.h
index f7755acd96..b7cfde7033 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -3488,6 +3488,9 @@ bool update_window_fringes (struct window *, bool);
void gui_init_fringe (struct redisplay_interface *);
+extern int max_used_fringe_bitmap;
+void gui_define_fringe_bitmap (struct frame *, int);
+
#ifdef HAVE_NTGUI
void w32_reset_fringes (void);
#endif
diff --git a/src/fringe.c b/src/fringe.c
index 4ea368d215..bc4e0f1f13 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -1823,6 +1823,23 @@ gui_init_fringe (struct redisplay_interface *rif)
}
}
+/* Call frame F's specific define_fringe_bitmap method for a fringe
+ bitmap number N. Called by various *term.c functions when they
+ need to display a fringe bitmap whose terminal-specific data is not
+ available. */
+void
+gui_define_fringe_bitmap (struct frame *f, int n)
+{
+ struct redisplay_interface *rif = FRAME_RIF (f);
+
+ if (!rif || !rif->define_fringe_bitmap || n >= max_used_fringe_bitmap)
+ return;
+
+ struct fringe_bitmap *fb = fringe_bitmaps[n];
+ if (fb)
+ rif->define_fringe_bitmap (n, fb->bits, fb->height, fb->width);
+}
+
#ifdef HAVE_NTGUI
void
w32_reset_fringes (void)
diff --git a/src/w32term.c b/src/w32term.c
index 78777f153c..9094843f60 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -794,12 +794,25 @@ w32_draw_fringe_bitmap (struct window *w, struct
glyph_row *row,
w32_fill_area (f, hdc, face->background,
p->bx, p->by, p->nx, p->ny);
- if (p->which && p->which < max_fringe_bmp)
+ if (p->which
+ && p->which < max_fringe_bmp
+ && p->which < max_used_fringe_bitmap)
{
HBITMAP pixmap = fringe_bmp[p->which];
HDC compat_hdc;
HANDLE horig_obj;
+ if (!fringe_bmp[p->which])
+ {
+ /* This fringe bitmap is known to fringe.c, but lacks the
+ HBITMAP data which shadows that bitmap. This is typical
+ to define-fringe-bitmap being called when the selected
+ frame was not a GUI frame, for example, when packages
+ that define fringe bitmaps are loaded by a daemon Emacs.
+ Create the missing HBITMAP now. */
+ gui_define_fringe_bitmap (f, p->which);
+ }
+
compat_hdc = CreateCompatibleDC (hdc);
SaveDC (hdc);
diff --git a/src/xterm.c b/src/xterm.c
index b6c200a27a..2563fb31a5 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -2640,7 +2640,9 @@ x_draw_fringe_bitmap (struct window *w, struct glyph_row
*row, struct draw_fring
}
#ifdef USE_CAIRO
- if (p->which && p->which < max_fringe_bmp)
+ if (p->which
+ && p->which < max_fringe_bmp
+ && p->which < max_used_fringe_bitmap)
{
XGCValues gcv;
@@ -2650,6 +2652,16 @@ x_draw_fringe_bitmap (struct window *w, struct glyph_row
*row, struct draw_fring
: f->output_data.x->cursor_pixel)
: face->foreground));
XSetBackground (display, gc, face->background);
+ if (!fringe_bmp[p->which])
+ {
+ /* This fringe bitmap is known to fringe.c, but lacks the
+ cairo_pattern_t pattern which shadows that bitmap. This
+ is typical to define-fringe-bitmap being called when the
+ selected frame was not a GUI frame, for example, when
+ packages that define fringe bitmaps are loaded by a
+ daemon Emacs. Create the missing pattern now. */
+ gui_define_fringe_bitmap (f, p->which);
+ }
x_cr_draw_image (f, gc, fringe_bmp[p->which], 0, p->dh,
p->wd, p->h, p->x, p->y, p->overlay_p);
XSetForeground (display, gc, gcv.foreground);