mirror of
				https://github.com/tmux/tmux.git
				synced 2025-10-26 12:27:15 +00:00 
			
		
		
		
	Stop crashing when exiting windows.
This commit is contained in:
		
							
								
								
									
										16
									
								
								session.c
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								session.c
									
									
									
									
									
								
							| @@ -1,4 +1,4 @@ | |||||||
| /* $Id: session.c,v 1.14 2007-09-21 20:02:23 nicm Exp $ */ | /* $Id: session.c,v 1.15 2007-09-21 20:45:05 nicm Exp $ */ | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> |  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> | ||||||
| @@ -129,20 +129,16 @@ session_attach(struct session *s, struct window *w) | |||||||
| int | int | ||||||
| session_detach(struct session *s, struct window *w) | session_detach(struct session *s, struct window *w) | ||||||
| { | { | ||||||
|  | 	if (s->window == w && session_last(s) != 0 && session_previous(s) != 0) | ||||||
|  | 		session_next(s); | ||||||
|  | 	if (s->last == w) | ||||||
|  | 		s->last = NULL; | ||||||
|  |  | ||||||
| 	window_remove(&s->windows, w); | 	window_remove(&s->windows, w); | ||||||
| 	if (ARRAY_EMPTY(&s->windows)) { | 	if (ARRAY_EMPTY(&s->windows)) { | ||||||
| 		session_destroy(s); | 		session_destroy(s); | ||||||
| 		return (1); | 		return (1); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (s->last == w) |  | ||||||
| 		s->last = NULL; |  | ||||||
| 	if (s->window == w) { |  | ||||||
| 		/* Reset s->window to stop it ending up in s->last. */ |  | ||||||
| 		s->window = NULL; |  | ||||||
| 		if (session_last(s) != 0 && session_previous(s) != 0) |  | ||||||
| 			session_next(s); |  | ||||||
| 	} |  | ||||||
| 	return (0); | 	return (0); | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										5
									
								
								window.c
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								window.c
									
									
									
									
									
								
							| @@ -1,4 +1,4 @@ | |||||||
| /* $Id: window.c,v 1.9 2007-09-21 18:20:44 nicm Exp $ */ | /* $Id: window.c,v 1.10 2007-09-21 20:45:06 nicm Exp $ */ | ||||||
|  |  | ||||||
| /* | /* | ||||||
|  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> |  * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> | ||||||
| @@ -181,9 +181,8 @@ window_remove(struct windows *ww, struct window *w) | |||||||
|  |  | ||||||
| 	if (window_index(ww, w, &i) != 0) | 	if (window_index(ww, w, &i) != 0) | ||||||
| 		fatalx("window not found"); | 		fatalx("window not found"); | ||||||
| 	if (i != ARRAY_LENGTH(ww) - 1) |  | ||||||
| 	ARRAY_SET(ww, i, NULL); | 	ARRAY_SET(ww, i, NULL); | ||||||
| 	else | 	while (!ARRAY_EMPTY(ww) && ARRAY_LAST(ww) == NULL) | ||||||
| 		ARRAY_TRUNC(ww, 1); | 		ARRAY_TRUNC(ww, 1); | ||||||
|  |  | ||||||
| 	w->references--; | 	w->references--; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Nicholas Marriott
					Nicholas Marriott