From 45ba6f1feded1c1ece03c85401b959adc8bbd93a Mon Sep 17 00:00:00 2001 From: James Booth Date: Wed, 17 Sep 2014 23:21:14 +0100 Subject: Added autocompletion for form text-multi values --- src/tools/autocomplete.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src/tools') diff --git a/src/tools/autocomplete.c b/src/tools/autocomplete.c index efff6ee0..842ec22a 100644 --- a/src/tools/autocomplete.c +++ b/src/tools/autocomplete.c @@ -115,19 +115,21 @@ autocomplete_add(Autocomplete ac, const char *item) void autocomplete_remove(Autocomplete ac, const char * const item) { - GSList *curr = g_slist_find_custom(ac->items, item, (GCompareFunc)strcmp); + if (ac != NULL) { + GSList *curr = g_slist_find_custom(ac->items, item, (GCompareFunc)strcmp); - if (!curr) { - return; - } + if (!curr) { + return; + } - // reset last found if it points to the item to be removed - if (ac->last_found == curr) { - ac->last_found = NULL; - } + // reset last found if it points to the item to be removed + if (ac->last_found == curr) { + ac->last_found = NULL; + } - free(curr->data); - ac->items = g_slist_delete_link(ac->items, curr); + free(curr->data); + ac->items = g_slist_delete_link(ac->items, curr); + } return; } -- cgit