diff options
| author | Martin Rudalics | 2011-01-14 21:55:58 -0500 |
|---|---|---|
| committer | Chong Yidong | 2011-01-14 21:55:58 -0500 |
| commit | 6dc1d2d387edd0e2dc301871134a071af5d0744a (patch) | |
| tree | f6a487de14f3d91427d98a2fc0bcac2295b7ebde /src | |
| parent | b024d9f02d2758815069b2a0df3af72fcf0ee220 (diff) | |
| download | emacs-6dc1d2d387edd0e2dc301871134a071af5d0744a.tar.gz emacs-6dc1d2d387edd0e2dc301871134a071af5d0744a.zip | |
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).
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 8 | ||||
| -rw-r--r-- | src/window.c | 34 |
2 files changed, 24 insertions, 18 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index dbb7be762a8..3a65048f057 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2011-01-15 Martin Rudalics <rudalics@gmx.at> | ||
| 2 | |||
| 3 | * window.c (inhibit_point_swap): New variable. | ||
| 4 | (Fselect_window): If inhibit_point_swap is nonzero, avoid swapping | ||
| 5 | point this time. | ||
| 6 | (Fset_window_configuration): Set inhibit_point_swap to 1 instead | ||
| 7 | of setting selected_window to nil (Bug#7728). | ||
| 8 | |||
| 1 | 2011-01-12 Chong Yidong <cyd@stupidchicken.com> | 9 | 2011-01-12 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 10 | ||
| 3 | * config.in (TERMINFO): New definition. | 11 | * config.in (TERMINFO): New definition. |
diff --git a/src/window.c b/src/window.c index 73fd2c79f2c..8b4324f2697 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -158,6 +158,11 @@ static int sequence_number; | |||
| 158 | 158 | ||
| 159 | static int window_initialized; | 159 | static int window_initialized; |
| 160 | 160 | ||
| 161 | /* Set in `set-window-configuration' to prevent "swapping out point" | ||
| 162 | in the old selected window. */ | ||
| 163 | |||
| 164 | static int inhibit_point_swap; | ||
| 165 | |||
| 161 | /* Hook to run when window config changes. */ | 166 | /* Hook to run when window config changes. */ |
| 162 | 167 | ||
| 163 | static Lisp_Object Qwindow_configuration_change_hook; | 168 | static Lisp_Object Qwindow_configuration_change_hook; |
| @@ -186,11 +191,6 @@ static int window_scroll_pixel_based_preserve_y; | |||
| 186 | static int window_scroll_preserve_hpos; | 191 | static int window_scroll_preserve_hpos; |
| 187 | static int window_scroll_preserve_vpos; | 192 | static int window_scroll_preserve_vpos; |
| 188 | 193 | ||
| 189 | #if 0 /* This isn't used anywhere. */ | ||
| 190 | /* Nonzero means we can split a frame even if it is "unsplittable". */ | ||
| 191 | static int inhibit_frame_unsplittable; | ||
| 192 | #endif /* 0 */ | ||
| 193 | |||
| 194 | extern EMACS_INT scroll_margin; | 194 | extern EMACS_INT scroll_margin; |
| 195 | 195 | ||
| 196 | extern Lisp_Object Qwindow_scroll_functions, Vwindow_scroll_functions; | 196 | extern Lisp_Object Qwindow_scroll_functions, Vwindow_scroll_functions; |
| @@ -3638,7 +3638,9 @@ selected window before each command. */) | |||
| 3638 | /* Store the current buffer's actual point into the | 3638 | /* Store the current buffer's actual point into the |
| 3639 | old selected window. It belongs to that window, | 3639 | old selected window. It belongs to that window, |
| 3640 | and when the window is not selected, must be in the window. */ | 3640 | and when the window is not selected, must be in the window. */ |
| 3641 | if (!NILP (selected_window)) | 3641 | if (inhibit_point_swap) |
| 3642 | inhibit_point_swap = 0; | ||
| 3643 | else | ||
| 3642 | { | 3644 | { |
| 3643 | ow = XWINDOW (selected_window); | 3645 | ow = XWINDOW (selected_window); |
| 3644 | if (! NILP (ow->buffer)) | 3646 | if (! NILP (ow->buffer)) |
| @@ -5861,7 +5863,7 @@ zero means top of window, negative means relative to bottom of window. */) | |||
| 5861 | /* This test is needed to make sure PT/PT_BYTE make sense in w->buffer | 5863 | /* This test is needed to make sure PT/PT_BYTE make sense in w->buffer |
| 5862 | when passed below to set_marker_both. */ | 5864 | when passed below to set_marker_both. */ |
| 5863 | error ("move-to-window-line called from unrelated buffer"); | 5865 | error ("move-to-window-line called from unrelated buffer"); |
| 5864 | 5866 | ||
| 5865 | window = selected_window; | 5867 | window = selected_window; |
| 5866 | start = marker_position (w->start); | 5868 | start = marker_position (w->start); |
| 5867 | if (start < BEGV || start > ZV) | 5869 | if (start < BEGV || start > ZV) |
| @@ -6241,10 +6243,6 @@ the return value is nil. Otherwise the value is t. */) | |||
| 6241 | } | 6243 | } |
| 6242 | 6244 | ||
| 6243 | FRAME_ROOT_WINDOW (f) = data->root_window; | 6245 | FRAME_ROOT_WINDOW (f) = data->root_window; |
| 6244 | /* Prevent "swapping out point" in the old selected window | ||
| 6245 | using the buffer that has been restored into it. | ||
| 6246 | We already swapped out point that from that window's old buffer. */ | ||
| 6247 | selected_window = Qnil; | ||
| 6248 | 6246 | ||
| 6249 | /* Arrange *not* to restore point in the buffer that was | 6247 | /* Arrange *not* to restore point in the buffer that was |
| 6250 | current when the window configuration was saved. */ | 6248 | current when the window configuration was saved. */ |
| @@ -6253,6 +6251,11 @@ the return value is nil. Otherwise the value is t. */) | |||
| 6253 | make_number (old_point), | 6251 | make_number (old_point), |
| 6254 | XWINDOW (data->current_window)->buffer); | 6252 | XWINDOW (data->current_window)->buffer); |
| 6255 | 6253 | ||
| 6254 | /* In the following call to `select-window, prevent "swapping | ||
| 6255 | out point" in the old selected window using the buffer that | ||
| 6256 | has been restored into it. We already swapped out that point | ||
| 6257 | from that window's old buffer. */ | ||
| 6258 | inhibit_point_swap = 1; | ||
| 6256 | Fselect_window (data->current_window, Qnil); | 6259 | Fselect_window (data->current_window, Qnil); |
| 6257 | XBUFFER (XWINDOW (selected_window)->buffer)->last_selected_window | 6260 | XBUFFER (XWINDOW (selected_window)->buffer)->last_selected_window |
| 6258 | = selected_window; | 6261 | = selected_window; |
| @@ -6262,13 +6265,6 @@ the return value is nil. Otherwise the value is t. */) | |||
| 6262 | && FRAME_LIVE_P (XFRAME (data->focus_frame)))) | 6265 | && FRAME_LIVE_P (XFRAME (data->focus_frame)))) |
| 6263 | Fredirect_frame_focus (frame, data->focus_frame); | 6266 | Fredirect_frame_focus (frame, data->focus_frame); |
| 6264 | 6267 | ||
| 6265 | #if 0 /* I don't understand why this is needed, and it causes problems | ||
| 6266 | when the frame's old selected window has been deleted. */ | ||
| 6267 | if (f != selected_frame && FRAME_WINDOW_P (f)) | ||
| 6268 | do_switch_frame (WINDOW_FRAME (XWINDOW (data->root_window)), | ||
| 6269 | 0, 0, Qnil); | ||
| 6270 | #endif | ||
| 6271 | |||
| 6272 | /* Set the screen height to the value it had before this function. */ | 6268 | /* Set the screen height to the value it had before this function. */ |
| 6273 | if (previous_frame_lines != FRAME_LINES (f) | 6269 | if (previous_frame_lines != FRAME_LINES (f) |
| 6274 | || previous_frame_cols != FRAME_COLS (f)) | 6270 | || previous_frame_cols != FRAME_COLS (f)) |
| @@ -7218,6 +7214,8 @@ syms_of_window () | |||
| 7218 | window_scroll_preserve_hpos = -1; | 7214 | window_scroll_preserve_hpos = -1; |
| 7219 | window_scroll_preserve_vpos = -1; | 7215 | window_scroll_preserve_vpos = -1; |
| 7220 | 7216 | ||
| 7217 | inhibit_point_swap = 0; | ||
| 7218 | |||
| 7221 | DEFVAR_LISP ("temp-buffer-show-function", &Vtemp_buffer_show_function, | 7219 | DEFVAR_LISP ("temp-buffer-show-function", &Vtemp_buffer_show_function, |
| 7222 | doc: /* Non-nil means call as function to display a help buffer. | 7220 | doc: /* Non-nil means call as function to display a help buffer. |
| 7223 | The function is called with one argument, the buffer to be displayed. | 7221 | The function is called with one argument, the buffer to be displayed. |