emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r107391: Avoid infloop in next-frame


From: Chong Yidong
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r107391: Avoid infloop in next-frame during frame creation.
Date: Thu, 23 Feb 2012 15:28:21 +0800
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 107391
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Thu 2012-02-23 15:28:21 +0800
message:
  Avoid infloop in next-frame during frame creation.
  
  See thread at 
http://lists.gnu.org/archive/html/emacs-devel/2012-02/msg00573.html
  
  * src/window.c (inhibit_window_configuration_change_hook): New var.
  (run_window_configuration_change_hook): Obey it.
  
  * src/xfns.c (Fx_create_frame): Avoid window-configuration-change-hook
  call when setting menu-bar-lines and tool-bar-lines parameters.
  (unwind_create_frame_1): New helper function.
modified:
  src/ChangeLog
  src/window.c
  src/window.h
  src/xfns.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-02-22 06:03:30 +0000
+++ b/src/ChangeLog     2012-02-23 07:28:21 +0000
@@ -1,3 +1,12 @@
+2012-02-23  Chong Yidong  <address@hidden>
+
+       * xfns.c (Fx_create_frame): Avoid window-configuration-change-hook
+       call when setting menu-bar-lines and tool-bar-lines parameters.
+       (unwind_create_frame_1): New helper function.
+
+       * window.c (inhibit_window_configuration_change_hook): New var.
+       (run_window_configuration_change_hook): Obey it.
+
 2012-02-22  Chong Yidong  <address@hidden>
 
        * xterm.c (x_draw_image_relief): Add missing type check for

=== modified file 'src/window.c'
--- a/src/window.c      2012-02-12 04:29:50 +0000
+++ b/src/window.c      2012-02-23 07:28:21 +0000
@@ -122,6 +122,9 @@
 /* Hook to run when window config changes.  */
 static Lisp_Object Qwindow_configuration_change_hook;
 
+/* If non-nil, run_window_configuration_change_hook does nothing.  */
+Lisp_Object inhibit_window_configuration_change_hook;
+
 /* Used by the function window_scroll_pixel_based */
 static int window_scroll_pixel_based_preserve_x;
 static int window_scroll_pixel_based_preserve_y;
@@ -2894,7 +2897,7 @@
     = Fdefault_value (Qwindow_configuration_change_hook);
   XSETFRAME (frame, f);
 
-  if (NILP (Vrun_hooks))
+  if (NILP (Vrun_hooks) || !NILP (inhibit_window_configuration_change_hook))
     return;
 
   /* Use the right buffer.  Matters when running the local hooks.  */

=== modified file 'src/window.h'
--- a/src/window.h      2012-01-19 07:21:25 +0000
+++ b/src/window.h      2012-02-23 07:28:21 +0000
@@ -810,6 +810,10 @@
 
 extern Lisp_Object Vmouse_event;
 
+/* If non-nil, run_window_configuration_change_hook does nothing.  */
+
+extern Lisp_Object inhibit_window_configuration_change_hook;
+
 EXFUN (Fnext_window, 3);
 EXFUN (Fselect_window, 2);
 EXFUN (Fset_window_buffer, 3);

=== modified file 'src/xfns.c'
--- a/src/xfns.c        2012-01-19 07:21:25 +0000
+++ b/src/xfns.c        2012-02-23 07:28:21 +0000
@@ -2949,6 +2949,12 @@
   return Qnil;
 }
 
+static Lisp_Object
+unwind_create_frame_1 (Lisp_Object val)
+{
+  inhibit_window_configuration_change_hook = val;
+  return Qnil;
+}
 
 static void
 x_default_font_parameter (struct frame *f, Lisp_Object parms)
@@ -3321,17 +3327,31 @@
      happen.  */
   init_frame_faces (f);
 
-  /* The X resources controlling the menu-bar and tool-bar are
-     processed specially at startup, and reflected in the mode
-     variables; ignore them here.  */
-  x_default_parameter (f, parms, Qmenu_bar_lines,
-                      NILP (Vmenu_bar_mode)
-                      ? make_number (0) : make_number (1),
-                      NULL, NULL, RES_TYPE_NUMBER);
-  x_default_parameter (f, parms, Qtool_bar_lines,
-                      NILP (Vtool_bar_mode)
-                      ? make_number (0) : make_number (1),
-                      NULL, NULL, RES_TYPE_NUMBER);
+  /* Set the menu-bar-lines and tool-bar-lines parameters.  We don't
+     look up the X resources controlling the menu-bar and tool-bar
+     here; they are processed specially at startup, and reflected in
+     the values of the mode variables.
+
+     Avoid calling window-configuration-change-hook; otherwise we
+     could get an infloop in next_frame since the frame is not yet in
+     Vframe_list.  */
+  {
+    int count2 = SPECPDL_INDEX ();
+    record_unwind_protect (unwind_create_frame_1,
+                          inhibit_window_configuration_change_hook);
+    inhibit_window_configuration_change_hook = Qt;
+
+    x_default_parameter (f, parms, Qmenu_bar_lines,
+                        NILP (Vmenu_bar_mode)
+                        ? make_number (0) : make_number (1),
+                        NULL, NULL, RES_TYPE_NUMBER);
+    x_default_parameter (f, parms, Qtool_bar_lines,
+                        NILP (Vtool_bar_mode)
+                        ? make_number (0) : make_number (1),
+                        NULL, NULL, RES_TYPE_NUMBER);
+
+    unbind_to (count2, Qnil);
+  }
 
   x_default_parameter (f, parms, Qbuffer_predicate, Qnil,
                       "bufferPredicate", "BufferPredicate",


reply via email to

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