From 03e8564cb45ff061a628492b2df7d0540ba06040 Mon Sep 17 00:00:00 2001 From: Alastair Poole Date: Sun, 2 Feb 2020 19:21:48 +0000 Subject: [PATCH] search: Cancel thread when closing. We need to ensure we cancel the search thread especially on exit to avoid a SEGV due to some horrible side-effects of EFL shutting down as we search. --- src/bin/edi_main.c | 1 + src/bin/edi_searchpanel.c | 16 ++++++++++------ src/bin/edi_searchpanel.h | 7 +++++++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/bin/edi_main.c b/src/bin/edi_main.c index b5d4960..ac96fcc 100644 --- a/src/bin/edi_main.c +++ b/src/bin/edi_main.c @@ -1783,6 +1783,7 @@ edi_open(const char *inputpath) void edi_close() { + edi_searchpanel_stop(); edi_debugpanel_stop(); elm_exit(); } diff --git a/src/bin/edi_searchpanel.c b/src/bin/edi_searchpanel.c index c2af150..65e9d6d 100644 --- a/src/bin/edi_searchpanel.c +++ b/src/bin/edi_searchpanel.c @@ -33,6 +33,13 @@ _edi_searchpanel_config_changed_cb(void *data EINA_UNUSED, int type EINA_UNUSED, return ECORE_CALLBACK_RENEW; } +void +edi_searchpanel_stop(void) +{ + if (_search_thread) + ecore_thread_cancel(_search_thread); +} + static void _edi_searchpanel_line_clicked_cb(void *data EINA_UNUSED, const Efl_Event *event) { @@ -498,13 +505,10 @@ _edi_searchpanel_search_project(const char *directory, const char *search_term, { case EINA_FILE_REG: { + if (ecore_thread_check(_search_thread)) return; + const char *mime = edi_mime_type_get(info->path); - if (!mime) - { - // If we're in a search and EDI is shutting down we - // need to return here. - return; - } + if (strncmp(mime, "text/", 5)) break; diff --git a/src/bin/edi_searchpanel.h b/src/bin/edi_searchpanel.h index 409a2d3..244bfb6 100644 --- a/src/bin/edi_searchpanel.h +++ b/src/bin/edi_searchpanel.h @@ -32,6 +32,13 @@ extern "C" { */ void edi_searchpanel_add(Evas_Object *parent); +/** + * Cancel a search that is in progress. + * + * @ingroup UI + */ +void edi_searchpanel_stop(void); + /** * Show the Edi searchpanel - animating on to screen if required. *