diff --git a/src/call.cpp b/src/call.cpp index b61b2fd75cae5ffea45ac8ae7459afed63c33cbb..b87da1ad8d1ab326cf93ae4baed88e431e859f27 100644 --- a/src/call.cpp +++ b/src/call.cpp @@ -539,9 +539,12 @@ Call::checkPendingIM() Manager::instance().incomingMessage(getCallId(), getPeerNumber(), msg.first); pendingInMessages_.clear(); - for (const auto& msg : pendingOutMessages_) - sendTextMessage(msg.first, msg.second); - pendingOutMessages_.clear(); + std::weak_ptr<Call> callWkPtr = shared_from_this(); + runOnMainThread([callWkPtr, pending = std::move(pendingOutMessages_)]{ + if (auto call = callWkPtr.lock()) + for (const auto& msg : pending) + call->sendTextMessage(msg.first, msg.second); + }); } } } diff --git a/src/client/callmanager.cpp b/src/client/callmanager.cpp index e59d435ae60f7de3946af845ddaf796cedefcd9d..25a743a45dc645fb01a5048ed170ba37bfa0525a 100644 --- a/src/client/callmanager.cpp +++ b/src/client/callmanager.cpp @@ -317,7 +317,9 @@ switchInput(const std::string& callID, const std::string& resource) void sendTextMessage(const std::string& callID, const std::map<std::string, std::string>& messages, const std::string& from, bool isMixed) { - jami::Manager::instance().sendCallTextMessage(callID, messages, from, isMixed); + jami::runOnMainThread([callID, messages, from, isMixed]{ + jami::Manager::instance().sendCallTextMessage(callID, messages, from, isMixed); + }); } } // namespace DRing diff --git a/src/sip/sipcall.cpp b/src/sip/sipcall.cpp index d719ae44e0a13de01b4074a853f544d88b2c01bb..773195e0174a08485249150299131689c7467597 100644 --- a/src/sip/sipcall.cpp +++ b/src/sip/sipcall.cpp @@ -706,6 +706,7 @@ void SIPCall::sendTextMessage(const std::map<std::string, std::string>& messages, const std::string& from) { + std::lock_guard<std::recursive_mutex> lk {callMutex_}; //TODO: for now we ignore the "from" (the previous implementation for sending this info was // buggy and verbose), another way to send the original message sender will be implemented // in the future