From cc538a85081bce68112c46c41d4b161adda7d08d Mon Sep 17 00:00:00 2001 From: Bowon Ryu Date: Tue, 24 May 2016 11:58:35 +0900 Subject: [PATCH] edc_parser&autocomp: Fix double click issue on WindowsOS Summary: Enventor window stops responding on double clicking "min" on Windows. Because of approaching the index in which the cur_context doesn't exist, the crash happens. *cur_context[] in parser_attribute_get() edc_parser.c Test Plan: 1. launch enventor on Windows 2. add image using live edit 3. double click "min" on editor @TSAM-3524 Reviewers: Jaehyun_Cho, Hermet Differential Revision: https://phab.enlightenment.org/D3972 --- src/lib/auto_comp.c | 3 ++- src/lib/edc_parser.c | 15 +++++++++------ src/lib/enventor_private.h | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/lib/auto_comp.c b/src/lib/auto_comp.c index 685c643..d7e7adc 100644 --- a/src/lib/auto_comp.c +++ b/src/lib/auto_comp.c @@ -932,12 +932,13 @@ autocomp_enabled_get(void) } const char ** -autocomp_current_context_get(void) +autocomp_current_context_get(int *name_count) { autocomp_data *ad = g_ad; if (!ad->lexem_ptr || !ad->lexem_ptr->name) return NULL; + *name_count = ad->lexem_ptr->name_count; return (const char **)ad->lexem_ptr->name; } diff --git a/src/lib/edc_parser.c b/src/lib/edc_parser.c index 165897d..7df6088 100644 --- a/src/lib/edc_parser.c +++ b/src/lib/edc_parser.c @@ -1547,8 +1547,9 @@ parser_attribute_get(parser_data *pd, const char *text, const char *cur, } if (instring) return NULL; - const char **cur_context = autocomp_current_context_get(); - int i = 0; + int name_count; + const char **cur_context = autocomp_current_context_get(&name_count); + int i; EINA_INARRAY_FOREACH(pd->attrs, attr) { @@ -1557,11 +1558,13 @@ parser_attribute_get(parser_data *pd, const char *text, const char *cur, if (!attr->context) return &attr->value; - while (cur_context && (cur_context[i] != NULL)) + if (cur_context) { - if (!strcmp(cur_context[i], attr->context)) - return &attr->value; - i++; + for (i = 0; i < name_count; i++) + { + if (!strcmp(cur_context[i], attr->context)) + return &attr->value; + } } } } diff --git a/src/lib/enventor_private.h b/src/lib/enventor_private.h index 2096459..bd4f7df 100644 --- a/src/lib/enventor_private.h +++ b/src/lib/enventor_private.h @@ -89,7 +89,7 @@ Eina_Bool autocomp_enabled_get(void); Eina_Bool autocomp_event_dispatch(const char *key); void autocomp_list_show(void); void autocomp_reset(void); -const char **autocomp_current_context_get(void); +const char **autocomp_current_context_get(int *name_count); /* syntax color */