From fbce7560076c2217c78b081e77f1a694d6aa9fb8 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 17 Feb 2020 16:12:07 +0100 Subject: [PATCH] JsonRpcConnection#Send*Message(): keep this alive --- lib/remote/jsonrpcconnection.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/remote/jsonrpcconnection.cpp b/lib/remote/jsonrpcconnection.cpp index b6d1d41e6..2811a45fb 100644 --- a/lib/remote/jsonrpcconnection.cpp +++ b/lib/remote/jsonrpcconnection.cpp @@ -170,12 +170,16 @@ ConnectionRole JsonRpcConnection::GetRole() const void JsonRpcConnection::SendMessage(const Dictionary::Ptr& message) { - m_IoStrand.post([this, message]() { SendMessageInternal(message); }); + Ptr keepAlive (this); + + m_IoStrand.post([this, keepAlive, message]() { SendMessageInternal(message); }); } void JsonRpcConnection::SendRawMessage(const String& message) { - m_IoStrand.post([this, message]() { + Ptr keepAlive (this); + + m_IoStrand.post([this, keepAlive, message]() { m_OutgoingMessagesQueue.emplace_back(message); m_OutgoingMessagesQueued.Set(); });