From 5c21533435fc6e7b89a1c0df2873ed23723a6438 Mon Sep 17 00:00:00 2001 From: eidheim Date: Fri, 26 Jun 2015 17:08:26 +0200 Subject: [PATCH] Fixed a crash when tab was closed before the parsing was done. Juci sometimes crashes when quitting, maybe while parsing for the first time. Will look into it. --- juci/source.cc | 7 +++++-- juci/source.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/juci/source.cc b/juci/source.cc index 8848c72..d053cac 100644 --- a/juci/source.cc +++ b/juci/source.cc @@ -163,13 +163,14 @@ parse_thread_go(true), parse_thread_mapped(false), parse_thread_stop(false) { parse_thread_go=true; }); - auto first_time_parse_done=this->terminal.PrintMessage("Parsing "+file_path, "finished"); - parse_done.connect([this, first_time_parse_done](){ + first_time_parse_done=this->terminal.PrintMessage("Parsing "+file_path, "finished"); + parse_done.connect([this](){ if(parse_thread_mapped) { INFO("Updating syntax"); update_syntax(extract_tokens(0, get_source_buffer()->get_text().size())); if(first_time_parse) { first_time_parse_done(); + first_time_parse_done=[](){}; first_time_parse=false; } INFO("Syntax updated"); @@ -214,6 +215,8 @@ Source::ClangView::~ClangView() { parse_thread.join(); parsing_mutex.lock(); //Be sure not to destroy while still parsing with libclang parsing_mutex.unlock(); + if(first_time_parse) + first_time_parse_done(); //This function must be run if it is not run already } void Source::ClangView:: diff --git a/juci/source.h b/juci/source.h index a09dad6..3c0a71d 100644 --- a/juci/source.h +++ b/juci/source.h @@ -110,6 +110,7 @@ namespace Source { bool on_key_release(GdkEventKey* key); Terminal::Controller& terminal; bool first_time_parse=true; + std::function first_time_parse_done; Glib::Dispatcher parse_done; Glib::Dispatcher parse_start;