Subject: bug#47832: 28.0.50; define-fringe-bitmap and emacs --daemon

From: Gregory Heytings <[email-masked]>
Date: Sat, 17 Apr 2021 12:52:08 +0000

>>> And in any case, the patch for gui_init_fringe is sub-optimal: it 
>>> unnecessarily loops over the standard bitmaps that were superseded. It 
>>> is better to leave the first loop go over the standard bitmaps, 
>>> whether superseded or not, and the second loop go over non-standard 
>>> bitmaps only.
>>
>> It is not sub-optimal, rif->define_fringe_bitmap will only be called 
>> for those standard bitmaps that were superseded.  For the 
>> non-superseded ones, fringe_bitmaps[bt] is NULL.
>
> I meant the first loop, not the second one.
>

Okay, the patch was meant only to fix the bug, but indeed the small 
optimization you mention makes sense.  Updated patch attached.

From d02af2c7007b2ba2ffa6c0fb47e33e65116808c4 Mon Sep 17 00:00:00 2001
From: Gregory Heytings <[email-masked]>
Date: Sat, 17 Apr 2021 12:48:48 +0000
Subject: [PATCH] Consider all user-defined bitmaps in gui_init_fringe()

* src/fringe.c (gui_init_fringe): Consider user-defined bitmaps that
override default ones (Bug#47832).
---
 src/fringe.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/fringe.c b/src/fringe.c
index 65c9a84ac9..47615f51f9 100644
--- a/src/fringe.c
+++ b/src/fringe.c
@@ -1776,14 +1776,15 @@ gui_init_fringe (struct redisplay_interface *rif)
   for (bt = NO_FRINGE_BITMAP + 1; bt < MAX_STANDARD_FRINGE_BITMAPS; bt++)
     {
       struct fringe_bitmap *fb = &standard_bitmaps[bt];
-      rif->define_fringe_bitmap (bt, fb->bits, fb->height, fb->width);
+      if (!fringe_bitmaps[bt])
+        rif->define_fringe_bitmap (bt, fb->bits, fb->height, fb->width);
     }
 
   /* Set up user-defined fringe bitmaps that might have been defined
      before the frame of this kind was initialized.  This can happen
      if Emacs is started as a daemon and the init files define fringe
      bitmaps.  */
-  for ( ; bt < max_used_fringe_bitmap; bt++)
+  for (bt = NO_FRINGE_BITMAP + 1; bt < max_used_fringe_bitmap; bt++)
     {
       struct fringe_bitmap *fb = fringe_bitmaps[bt];
       if (fb)
-- 
2.30.2