# HG changeset patch # User Chong Yidong # Date 1295060158 18000 # Node ID bee0a8fef127b76ad747f7d72851512f79d8540d # Parent 704fa1a3d5b48d4f6cfe5cf14008e00f4b1af5d3 Avoid crash in Fselect_frame due to null selected_window (Bug#7728). * window.c (inhibit_point_swap): New variable. (Fselect_window): If inhibit_point_swap is nonzero, avoid swapping point this time. (Fset_window_configuration): Set inhibit_point_swap to 1 instead of setting selected_window to nil (Bug#7728). diff -r 704fa1a3d5b4 -r bee0a8fef127 src/ChangeLog --- a/src/ChangeLog Fri Jan 14 21:32:19 2011 -0500 +++ b/src/ChangeLog Fri Jan 14 21:55:58 2011 -0500 @@ -1,3 +1,11 @@ +2011-01-15 Martin Rudalics + + * window.c (inhibit_point_swap): New variable. + (Fselect_window): If inhibit_point_swap is nonzero, avoid swapping + point this time. + (Fset_window_configuration): Set inhibit_point_swap to 1 instead + of setting selected_window to nil (Bug#7728). + 2011-01-12 Chong Yidong * config.in (TERMINFO): New definition. diff -r 704fa1a3d5b4 -r bee0a8fef127 src/window.c --- a/src/window.c Fri Jan 14 21:32:19 2011 -0500 +++ b/src/window.c Fri Jan 14 21:55:58 2011 -0500 @@ -158,6 +158,11 @@ static int window_initialized; +/* Set in `set-window-configuration' to prevent "swapping out point" + in the old selected window. */ + +static int inhibit_point_swap; + /* Hook to run when window config changes. */ static Lisp_Object Qwindow_configuration_change_hook; @@ -186,11 +191,6 @@ static int window_scroll_preserve_hpos; static int window_scroll_preserve_vpos; -#if 0 /* This isn't used anywhere. */ -/* Nonzero means we can split a frame even if it is "unsplittable". */ -static int inhibit_frame_unsplittable; -#endif /* 0 */ - extern EMACS_INT scroll_margin; extern Lisp_Object Qwindow_scroll_functions, Vwindow_scroll_functions; @@ -3638,7 +3638,9 @@ /* Store the current buffer's actual point into the old selected window. It belongs to that window, and when the window is not selected, must be in the window. */ - if (!NILP (selected_window)) + if (inhibit_point_swap) + inhibit_point_swap = 0; + else { ow = XWINDOW (selected_window); if (! NILP (ow->buffer)) @@ -5861,7 +5863,7 @@ /* This test is needed to make sure PT/PT_BYTE make sense in w->buffer when passed below to set_marker_both. */ error ("move-to-window-line called from unrelated buffer"); - + window = selected_window; start = marker_position (w->start); if (start < BEGV || start > ZV) @@ -6241,10 +6243,6 @@ } FRAME_ROOT_WINDOW (f) = data->root_window; - /* Prevent "swapping out point" in the old selected window - using the buffer that has been restored into it. - We already swapped out point that from that window's old buffer. */ - selected_window = Qnil; /* Arrange *not* to restore point in the buffer that was current when the window configuration was saved. */ @@ -6253,6 +6251,11 @@ make_number (old_point), XWINDOW (data->current_window)->buffer); + /* In the following call to `select-window, prevent "swapping + out point" in the old selected window using the buffer that + has been restored into it. We already swapped out that point + from that window's old buffer. */ + inhibit_point_swap = 1; Fselect_window (data->current_window, Qnil); XBUFFER (XWINDOW (selected_window)->buffer)->last_selected_window = selected_window; @@ -6262,13 +6265,6 @@ && FRAME_LIVE_P (XFRAME (data->focus_frame)))) Fredirect_frame_focus (frame, data->focus_frame); -#if 0 /* I don't understand why this is needed, and it causes problems - when the frame's old selected window has been deleted. */ - if (f != selected_frame && FRAME_WINDOW_P (f)) - do_switch_frame (WINDOW_FRAME (XWINDOW (data->root_window)), - 0, 0, Qnil); -#endif - /* Set the screen height to the value it had before this function. */ if (previous_frame_lines != FRAME_LINES (f) || previous_frame_cols != FRAME_COLS (f)) @@ -7218,6 +7214,8 @@ window_scroll_preserve_hpos = -1; window_scroll_preserve_vpos = -1; + inhibit_point_swap = 0; + DEFVAR_LISP ("temp-buffer-show-function", &Vtemp_buffer_show_function, doc: /* Non-nil means call as function to display a help buffer. The function is called with one argument, the buffer to be displayed.