Skip to content
Snippets Groups Projects
Commit d83bcfcf authored by Emmanuel Lepage Vallee's avatar Emmanuel Lepage Vallee Committed by Guillaume Roguez
Browse files

call: Handle daemon/libringclient IPC race condition

Refs #69138

(cherry picked from commit 19027630)
parent a5d526fc
No related branches found
No related tags found
No related merge requests found
......@@ -369,6 +369,13 @@ Call* CallPrivate::buildIncomingCall(const QString& callId)
const QString from = details[ CallPrivate::DetailsMapFields::PEER_NUMBER ];
const QString account = details[ CallPrivate::DetailsMapFields::ACCOUNT_ID ];
const QString peerName = details[ CallPrivate::DetailsMapFields::PEER_NAME ];
//It may be possible that the call has already been invalidated
if (account.isEmpty()) {
qWarning() << "Building incoming call" << callId << "failed, it may already have been destroyed by the daemon";
return nullptr;
}
Account* acc = AccountModel::instance()->getById(account.toLatin1());
ContactMethod* nb = PhoneDirectoryModel::instance()->getNumber(from,acc);
Call* call = new Call(Call::State::INCOMING, peerName, nb, acc);
......@@ -395,6 +402,13 @@ Call* CallPrivate::buildRingingCall(const QString & callId)
const QString from = details[ CallPrivate::DetailsMapFields::PEER_NUMBER ];
const QString account = details[ CallPrivate::DetailsMapFields::ACCOUNT_ID ];
const QString peerName = details[ CallPrivate::DetailsMapFields::PEER_NAME ];
//It may be possible that the call has already been invalidated
if (account.isEmpty()) {
qWarning() << "Building ringing call" << callId << "failed, it may already have been destroyed by the daemon";
return nullptr;
}
Account* acc = AccountModel::instance()->getById(account.toLatin1());
ContactMethod* nb = PhoneDirectoryModel::instance()->getNumber(from,acc);
Call* call = new Call(Call::State::RINGING, peerName, nb, acc);
......
......@@ -443,6 +443,11 @@ Call* CallModel::dialingCall(const QString& peerName, Account* account)
Call* CallModelPrivate::addIncomingCall(const QString& callId)
{
Call* call = addCall2(CallPrivate::buildIncomingCall(callId));
//The call can already have been invalidated by the daemon, then do nothing
if (!call)
return nullptr;
//Call without account is not possible
if (call->account()) {
if (call->account()->isAutoAnswer()) {
......@@ -459,7 +464,12 @@ Call* CallModelPrivate::addIncomingCall(const QString& callId)
///Create a ringing call
Call* CallModelPrivate::addRingingCall(const QString& callId)
{
return addCall2(CallPrivate::buildRingingCall(callId));
Call* c = CallPrivate::buildRingingCall(callId);
if (!c)
return nullptr;
return addCall2(c);
}
///Properly remove an internal from the Qt model
......@@ -1021,6 +1031,10 @@ void CallModelPrivate::slotCallStateChanged(const QString& callID, const QString
qDebug() << "Call not found" << callID << "new state" << stateName;
if(stateName == CallPrivate::StateChange::RINGING) {
call = addRingingCall(callID);
if (!call)
return;
}
else {
qDebug() << "Call doesn't exist in this client. Might have been initialized by another client instance before this one started.";
......@@ -1059,7 +1073,10 @@ void CallModelPrivate::slotIncomingCall(const QString& accountID, const QString&
{
Q_UNUSED(accountID)
qDebug() << "Signal : Incoming Call ! ID = " << callID;
emit q_ptr->incomingCall(addIncomingCall(callID));
Call* c = addIncomingCall(callID);
if (c)
emit q_ptr->incomingCall(c);
}
///When a new conference is incoming
......
......@@ -44,7 +44,7 @@ public:
//Helpers
static Account::RegistrationState fromDaemonName(const QString& st);
void enabledProtocol(Account::Protocol proto);
void enableProtocol(Account::Protocol proto);
//Attributes
AccountModel* q_ptr ;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment