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).
This commit is contained in:
Martin Rudalics 2011-01-14 21:55:58 -05:00 committed by Chong Yidong
parent b024d9f02d
commit 6dc1d2d387
2 changed files with 24 additions and 18 deletions

View file

@ -1,3 +1,11 @@
2011-01-15 Martin Rudalics <rudalics@gmx.at>
* 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 <cyd@stupidchicken.com>
* config.in (TERMINFO): New definition.

View file

@ -158,6 +158,11 @@ static int sequence_number;
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_pixel_based_preserve_y;
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 @@ selected window before each command. */)
/* 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 @@ zero means top of window, negative means relative to bottom of window. */)
/* 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 @@ the return value is nil. Otherwise the value is t. */)
}
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 @@ the return value is nil. Otherwise the value is t. */)
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 @@ the return value is nil. Otherwise the value is t. */)
&& 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 @@ syms_of_window ()
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.