From 41500249e3411db0dc7621a9ce5d0336e09d889a Mon Sep 17 00:00:00 2001 From: Oliver Frank Date: Sun, 23 Feb 2020 17:16:24 +0000 Subject: [PATCH] Fix crash after closing a GDScript LSP session (cherry picked from commit ed482f6167276bebd4132b82a6683392ac41f97a) --- .../gdscript/language_server/gdscript_language_protocol.cpp | 4 ++-- modules/gdscript/language_server/gdscript_language_protocol.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/gdscript/language_server/gdscript_language_protocol.cpp b/modules/gdscript/language_server/gdscript_language_protocol.cpp index 2eb1bb441e2..2243a7b81d1 100644 --- a/modules/gdscript/language_server/gdscript_language_protocol.cpp +++ b/modules/gdscript/language_server/gdscript_language_protocol.cpp @@ -122,7 +122,7 @@ Error GDScriptLanguageProtocol::LSPeer::send_data() { Error GDScriptLanguageProtocol::on_client_connected() { Ref tcp_peer = server->take_connection(); ERR_FAIL_COND_V_MSG(clients.size() >= LSP_MAX_CLIENTS, FAILED, "Max client limits reached"); - Ref peer = new LSPeer; + Ref peer = memnew(LSPeer); peer->connection = tcp_peer; clients.set(next_client_id, peer); next_client_id++; @@ -130,7 +130,7 @@ Error GDScriptLanguageProtocol::on_client_connected() { return OK; } -void GDScriptLanguageProtocol::on_client_disconnected(int p_client_id) { +void GDScriptLanguageProtocol::on_client_disconnected(const int &p_client_id) { clients.erase(p_client_id); EditorNode::get_log()->add_message("Disconnected", EditorLog::MSG_TYPE_EDITOR); } diff --git a/modules/gdscript/language_server/gdscript_language_protocol.h b/modules/gdscript/language_server/gdscript_language_protocol.h index 8596e0300e1..3f0ae36af25 100644 --- a/modules/gdscript/language_server/gdscript_language_protocol.h +++ b/modules/gdscript/language_server/gdscript_language_protocol.h @@ -77,7 +77,7 @@ private: Ref workspace; Error on_client_connected(); - void on_client_disconnected(int p_client_id); + void on_client_disconnected(const int &p_client_id); String process_message(const String &p_text); String format_output(const String &p_text);