From a76968da11712dc31ce1da34dc96cf69a0ac7c8e Mon Sep 17 00:00:00 2001 From: eidheim Date: Mon, 10 Aug 2020 14:10:34 +0200 Subject: [PATCH] Language client: fixed crash when renaming file: no longer attempts to reuse shutdown thread pool --- src/source_language_protocol.cpp | 8 +++++--- src/source_language_protocol.hpp | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/source_language_protocol.cpp b/src/source_language_protocol.cpp index 159d7f1..9309ed2 100644 --- a/src/source_language_protocol.cpp +++ b/src/source_language_protocol.cpp @@ -377,7 +377,7 @@ void Source::LanguageProtocolView::initialize() { update_status_state(this); set_editable(false); - thread_pool.push([this] { + initialize_thread = std::thread([this] { auto capabilities = client->initialize(this); dispatcher.post([this, capabilities] { @@ -412,14 +412,15 @@ void Source::LanguageProtocolView::close() { autocomplete_delayed_show_arguments_connection.disconnect(); update_type_coverage_connection.disconnect(); + if(initialize_thread.joinable()) + initialize_thread.join(); + if(autocomplete) { autocomplete->state = Autocomplete::State::idle; if(autocomplete->thread.joinable()) autocomplete->thread.join(); } - thread_pool.shutdown(true); - client->write_notification("textDocument/didClose", R"("textDocument":{"uri":")" + uri + "\"}"); client->close(this); client = nullptr; @@ -427,6 +428,7 @@ void Source::LanguageProtocolView::close() { Source::LanguageProtocolView::~LanguageProtocolView() { close(); + thread_pool.shutdown(true); } void Source::LanguageProtocolView::rename(const boost::filesystem::path &path) { diff --git a/src/source_language_protocol.hpp b/src/source_language_protocol.hpp index 272c1b9..2bd41fa 100644 --- a/src/source_language_protocol.hpp +++ b/src/source_language_protocol.hpp @@ -183,6 +183,7 @@ namespace Source { size_t document_version = 1; + std::thread initialize_thread; Dispatcher dispatcher; Glib::ThreadPool thread_pool;