Fixed a bug with resumed clients showing up twice in the clients list
git-svn-id: svn://svn.savannah.nongnu.org/lash/trunk@17 1de19dc7-4e3f-0410-a61d-eddf686bf0b7
This commit is contained in:
parent
b4ce2ac7d3
commit
f7c5c053da
|
@ -191,18 +191,35 @@ event_client_add(panel_t * panel, lash_event_t * event)
|
|||
const char *project_name = lash_event_get_project(event);
|
||||
project_t *project = get_project(panel, project_name);
|
||||
char *client_id_str = malloc(37);
|
||||
char *search_id_str = NULL;
|
||||
uuid_t client_id;
|
||||
GtkTreeIter iter;
|
||||
|
||||
GtkTreeModel *tree_model;
|
||||
int client_exists = FALSE;
|
||||
|
||||
lash_event_get_client_id(event, client_id);
|
||||
uuid_unparse(client_id, client_id_str);
|
||||
|
||||
printf("Add client (%s): %s\n", project_name, client_id_str);
|
||||
|
||||
if (client_id != NULL && project != NULL) {
|
||||
gtk_list_store_append(project->clients, &iter);
|
||||
gtk_list_store_set(project->clients, &iter,
|
||||
CLIENT_ID_COLUMN, client_id_str, -1);
|
||||
tree_model = GTK_TREE_MODEL(project->clients);
|
||||
|
||||
if (gtk_tree_model_get_iter_first(tree_model, &iter)) {
|
||||
do {
|
||||
gtk_tree_model_get(tree_model, &iter, CLIENT_ID_COLUMN, &search_id_str, -1);
|
||||
|
||||
if (!strcmp(search_id_str, client_id_str)) {
|
||||
client_exists = TRUE;
|
||||
break;
|
||||
}
|
||||
} while (gtk_tree_model_iter_next(tree_model, &iter));
|
||||
}
|
||||
if (!client_exists) {
|
||||
gtk_list_store_append(project->clients, &iter);
|
||||
gtk_list_store_set(project->clients, &iter,
|
||||
CLIENT_ID_COLUMN, client_id_str, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -295,6 +295,7 @@ void
|
|||
project_set_name(project_t * project, const char *const name)
|
||||
{
|
||||
assert(project != NULL);
|
||||
assert(name != NULL);
|
||||
free(project->name);
|
||||
project->name = calloc(strlen(name) + 1, sizeof(char));
|
||||
strncpy(project->name, name, strlen(name) + 1);
|
||||
|
@ -306,6 +307,7 @@ void
|
|||
project_set_dir(project_t * project, const char *const dir)
|
||||
{
|
||||
assert(project != NULL);
|
||||
assert(name != NULL);
|
||||
free(project->dir);
|
||||
project->dir = calloc(strlen(dir) + 1, sizeof(char));
|
||||
strncpy(project->dir, dir, strlen(dir) + 1);
|
||||
|
|
Loading…
Reference in New Issue