ajwillia-ms pushed a commit to branch master.

http://git.enlightenment.org/tools/edi.git/commit/?id=49f7506521d768c4e2cf8014a46443a58e76860e

commit 49f7506521d768c4e2cf8014a46443a58e76860e
Author: Andy Williams <[email protected]>
Date:   Mon Nov 28 01:46:07 2016 +0000

    highlight: cancel the file parsing on line events
    
    Either we have removed a line and could crash or we have
    added a line and everything will be off by one!
    
    This will get fixed moments later by the line change event
---
 src/bin/editor/edi_editor.c | 21 ++++++++++++++++++++-
 src/bin/editor/edi_editor.h |  1 +
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/bin/editor/edi_editor.c b/src/bin/editor/edi_editor.c
index 7222862..a8b3c71 100644
--- a/src/bin/editor/edi_editor.c
+++ b/src/bin/editor/edi_editor.c
@@ -341,6 +341,8 @@ _clang_show_highlighting(Edi_Editor *editor)
                 break;
           }
 
+        if (editor->highlight_cancel)
+          break;
         _edi_range_color_set(editor, range, type);
      }
 }
@@ -406,6 +408,8 @@ _clang_load_errors(const char *path EINA_UNUSED, Edi_Editor 
*editor)
         clang_disposeString(str);
 
         clang_disposeDiagnostic(diag);
+        if (editor->highlight_cancel)
+          break;
      }
 }
 
@@ -452,6 +456,7 @@ _edi_clang_dispose(void *data, Ecore_Thread *thread 
EINA_UNUSED)
    clang_disposeIndex(editor->idx);
 
    editor->highlight_thread = NULL;
+   editor->highlight_cancel = EINA_FALSE;
 }
 #endif
 
@@ -502,6 +507,18 @@ _mouse_up_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED,
 }
 
 static void
+_edi_editor_parse_line_cb(Elm_Code_Line *line EINA_UNUSED, void *data)
+{
+   Edi_Editor *editor = (Edi_Editor *)data;
+
+   // We have caused a reset in the file parser, if it is active
+   if (!editor->highlight_thread)
+     return;
+
+   editor->highlight_cancel = EINA_TRUE;
+}
+
+static void
 _edi_editor_parse_file_cb(Elm_Code_File *file EINA_UNUSED, void *data)
 {
    Edi_Editor *editor;
@@ -511,6 +528,7 @@ _edi_editor_parse_file_cb(Elm_Code_File *file EINA_UNUSED, 
void *data)
      return;
 
 #if HAVE_LIBCLANG
+   editor->highlight_cancel = EINA_FALSE;
    editor->highlight_thread = ecore_thread_run(_edi_clang_setup, 
_edi_clang_dispose, NULL, editor);
 #endif
 }
@@ -586,7 +604,8 @@ edi_editor_add(Evas_Object *parent, Edi_Mainview_Item *item)
 
    elm_code_parser_standard_add(code, ELM_CODE_PARSER_STANDARD_TODO);
    if (editor->show_highlight)
-     elm_code_parser_add(code, NULL, _edi_editor_parse_file_cb, editor);
+     elm_code_parser_add(code, _edi_editor_parse_line_cb,
+                              _edi_editor_parse_file_cb, editor);
    elm_code_file_open(code, item->path);
 
    evas_object_size_hint_weight_set(widget, EVAS_HINT_EXPAND, 
EVAS_HINT_EXPAND);
diff --git a/src/bin/editor/edi_editor.h b/src/bin/editor/edi_editor.h
index 33e7672..ce3404d 100644
--- a/src/bin/editor/edi_editor.h
+++ b/src/bin/editor/edi_editor.h
@@ -56,6 +56,7 @@ struct _Edi_Editor
 
    Eina_Bool show_highlight;
    Ecore_Thread *highlight_thread;
+   Eina_Bool highlight_cancel;
    time_t save_time;
 
    /* Add new members here. */

-- 


Reply via email to