about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMarco Peereboom <marco@conformal.com>2011-01-12 03:06:57 +0000
committerMarco Peereboom <marco@conformal.com>2011-01-12 03:06:57 +0000
commit431fd3b8df0c7a09bed5264d1a5b2cfe12688d18 (patch)
tree7b0786ad98c1afdcc66560c5bae65c0362fc54d5
parentac3b52d10bb2829d8996c842eed79177cdd33d10 (diff)
downloadxombrero-431fd3b8df0c7a09bed5264d1a5b2cfe12688d18.tar.gz
fix bug where during restart sometimes an extra tab got created.
-rw-r--r--xxxterm.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/xxxterm.c b/xxxterm.c
index 9cbc1e0..584303f 100644
--- a/xxxterm.c
+++ b/xxxterm.c
@@ -1556,8 +1556,9 @@ open_tabs(struct tab *t, struct karg *a)
 			if (feof(f) || ferror(f))
 				break;
 
-		if (uri && strlen(uri))
+		if (uri && strlen(uri)) {
 			create_new_tab(uri, NULL, 1);
+		}
 
 		free(uri);
 		uri = NULL;
@@ -1578,6 +1579,7 @@ restore_saved_tabs(void)
 	int		unlink_file = 0;
 	struct stat	sb;
 	struct karg	a;
+	int		rv = 0;
 
 	snprintf(file, sizeof file, "%s/%s",
 	    sessions_dir, XT_RESTART_TABS_FILE);
@@ -1588,12 +1590,12 @@ restore_saved_tabs(void)
 		a.s = XT_RESTART_TABS_FILE;
 	}
 
-	open_tabs(NULL, &a);
+	rv = open_tabs(NULL, &a);
 
 	if (unlink_file)
 		unlink(file);
 
-	return (1);
+	return (rv);
 }
 
 int
@@ -6322,7 +6324,7 @@ int
 main(int argc, char *argv[])
 {
 	struct stat		sb;
-	int			c, focus = 1, s, optn = 0;
+	int			c, s, optn = 0, focus = 1;
 	char			conf[PATH_MAX] = { '\0' };
 	char			file[PATH_MAX];
 	char			*env_proxy = NULL;
@@ -6546,10 +6548,10 @@ main(int argc, char *argv[])
 		restore_global_history();
 
 	if (!strcmp(named_session, XT_SAVED_TABS_FILE))
-		focus = restore_saved_tabs();
+		restore_saved_tabs();
 	else {
 		a.s = named_session;
-		focus = open_tabs(NULL, &a);
+		open_tabs(NULL, &a);
 	}
 
 	while (argc) {
@@ -6559,7 +6561,8 @@ main(int argc, char *argv[])
 		argc--;
 		argv++;
 	}
-	if (focus == 1)
+
+	if (TAILQ_EMPTY(&tabs))
 		create_new_tab(home, NULL, 1);
 
 	if (enable_socket)