Browse Source

Fix setting startup view by -w option. Fix force_viewname()

Serj Kalichev 10 years ago
parent
commit
f88c52a32a
2 changed files with 9 additions and 0 deletions
  1. 4 0
      clish/command/command.c
  2. 5 0
      clish/shell/shell_startup.c

+ 4 - 0
clish/command/command.c

@@ -260,6 +260,8 @@ void clish_command__set_viewname(clish_command_t * this, const char *viewname)
 /*--------------------------------------------------------- */
 void clish_command__force_viewname(clish_command_t * this, const char *viewname)
 {
+	if (this->viewname)
+		lub_string_free(this->viewname);
 	this->viewname = lub_string_dup(viewname);
 }
 
@@ -279,6 +281,8 @@ void clish_command__set_viewid(clish_command_t * this, const char *viewid)
 /*--------------------------------------------------------- */
 void clish_command__force_viewid(clish_command_t * this, const char *viewid)
 {
+	if (this->viewid)
+		lub_string_free(this->viewid);
 	this->viewid = lub_string_dup(viewid);
 }
 

+ 5 - 0
clish/shell/shell_startup.c

@@ -37,8 +37,13 @@ int clish_shell_startup(clish_shell_t *this)
 /*----------------------------------------------------------- */
 void clish_shell__set_startup_view(clish_shell_t *this, const char *viewname)
 {
+	clish_view_t *view;
+
 	assert(this);
 	assert(this->startup);
+	/* Search for the view */
+	view = clish_shell_find_view(this, viewname);
+	assert(view);
 	clish_command__force_viewname(this->startup, viewname);
 }