changeset 57813:6cc2262110d2

* xdisp.c (update_tool_bar): Pass a copy of f->tool_bar_items to tool_bar_items and assign the result to f->tool_bar_items if not equal. Move BLOCK/UNBLOCK_INPUT from around call to tool_bar_items to assignment of result.
author Jan Djärv <jan.h.d@swipnet.se>
date Sun, 31 Oct 2004 15:11:31 +0000
parents 938845bec845
children 1f473607c4a9
files src/ChangeLog src/xdisp.c
diffstat 2 files changed, 21 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Sun Oct 31 12:25:46 2004 +0000
+++ b/src/ChangeLog	Sun Oct 31 15:11:31 2004 +0000
@@ -1,5 +1,10 @@
 2004-10-31  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
 
+	* xdisp.c (update_tool_bar): Pass a copy of f->tool_bar_items to
+	tool_bar_items and assign the result to f->tool_bar_items if
+	not equal.  Move BLOCK/UNBLOCK_INPUT from around call to
+	tool_bar_items to assignment of result.
+
 	* atimer.c (alarm_signal_handler): Do not call set_alarm if
 	pending_atmers is non-zero.
 
--- a/src/xdisp.c	Sun Oct 31 12:25:46 2004 +0000
+++ b/src/xdisp.c	Sun Oct 31 15:11:31 2004 +0000
@@ -8416,7 +8416,8 @@
 	{
 	  struct buffer *prev = current_buffer;
 	  int count = SPECPDL_INDEX ();
-	  Lisp_Object old_tool_bar;
+	  Lisp_Object new_tool_bar;
+          int new_n_tool_bar;
 	  struct gcpro gcpro1;
 
 	  /* Set current_buffer to the buffer of the selected
@@ -8435,18 +8436,24 @@
 	      specbind (Qoverriding_local_map, Qnil);
 	    }
 
-	  old_tool_bar = f->tool_bar_items;
-	  GCPRO1 (old_tool_bar);
+	  GCPRO1 (new_tool_bar);
 
 	  /* Build desired tool-bar items from keymaps.  */
-          BLOCK_INPUT;
-	  f->tool_bar_items
-	    = tool_bar_items (f->tool_bar_items, &f->n_tool_bar_items);
-          UNBLOCK_INPUT;
+          new_tool_bar = tool_bar_items (Fcopy_sequence (f->tool_bar_items),
+                                         &new_n_tool_bar);
 
 	  /* Redisplay the tool-bar if we changed it.  */
-	  if (! NILP (Fequal (old_tool_bar, f->tool_bar_items)))
-	    w->update_mode_line = Qt;
+	  if (NILP (Fequal (new_tool_bar, f->tool_bar_items)))
+            {
+              /* Redisplay that happens asynchronously due to an expose event
+                 may access f->tool_bar_items.  Make sure we update both
+                 variables within BLOCK_INPUT so no such event interrupts.  */
+              BLOCK_INPUT;
+              f->tool_bar_items = new_tool_bar;
+              f->n_tool_bar_items = new_n_tool_bar;
+              w->update_mode_line = Qt;
+              UNBLOCK_INPUT;
+            }
 
 	  UNGCPRO;