From 5f884851699e87a769b9d5d906521ff3205d2f1f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Blin?=
 <sebastien.blin@savoirfairelinux.com>
Date: Mon, 10 Feb 2020 14:56:17 -0500
Subject: [PATCH] sipcall: avoid to block when hangup is called during
 onPeerRinging

Change-Id: Iada9a972ece86ea2536b9baa0b9e07b9bb2c35fc
---
 src/sip/sipcall.cpp | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/sip/sipcall.cpp b/src/sip/sipcall.cpp
index 9a348107a7..6e6a196b3e 100644
--- a/src/sip/sipcall.cpp
+++ b/src/sip/sipcall.cpp
@@ -392,7 +392,10 @@ SIPCall::hangup(int reason)
     // Stop all RTP streams
     stopAllMedia();
     setState(Call::ConnectionState::DISCONNECTED, reason);
-    removeCall();
+    runOnMainThread([w = weak()] {
+        if (auto shared = w.lock())
+            shared->removeCall();
+    });
 }
 
 void
@@ -822,7 +825,10 @@ SIPCall::sendKeyframe()
 void
 SIPCall::onPeerRinging()
 {
-    setState(ConnectionState::RINGING);
+    runOnMainThread([w = weak()] {
+        if (auto shared = w.lock())
+            shared->setState(ConnectionState::RINGING);
+    });
 }
 
 void
-- 
GitLab