Skip to content
Snippets Groups Projects
Commit 4103434a authored by Stepan Salenikovich's avatar Stepan Salenikovich Committed by gerrit2
Browse files

CallModel: disconnect from removed Call's signals

Once a call is removed (is over) we no longer need to be connected
to its signals. Notabely, this prevents warning logs about the
Call object not being found in the model if it changes.

Change-Id: I38281f2adceec10c8b5b751fb6f984d3084bf458
Tuleap: #1076
(cherry picked from commit 6b787030)
parent 5e4f35ac
No related branches found
No related tags found
No related merge requests found
...@@ -110,7 +110,7 @@ public: ...@@ -110,7 +110,7 @@ public:
void slotConferenceRemoved ( const QString& confId ); void slotConferenceRemoved ( const QString& confId );
void slotAddPrivateCall ( Call* call ); void slotAddPrivateCall ( Call* call );
void slotNewRecordingAvail ( const QString& callId , const QString& filePath); void slotNewRecordingAvail ( const QString& callId , const QString& filePath);
void slotCallChanged ( Call* call ); void slotCallChanged ( );
void slotStateChanged ( Call::State newState, Call::State previousState ); void slotStateChanged ( Call::State newState, Call::State previousState );
void slotDTMFPlayed ( const QString& str ); void slotDTMFPlayed ( const QString& str );
void slotRecordStateChanged ( const QString& callId , bool state ); void slotRecordStateChanged ( const QString& callId , bool state );
...@@ -466,7 +466,7 @@ Call* CallModelPrivate::addCall2(Call* call, Call* parentCall) ...@@ -466,7 +466,7 @@ Call* CallModelPrivate::addCall2(Call* call, Call* parentCall)
emit q_ptr->callAdded(call,parentCall); emit q_ptr->callAdded(call,parentCall);
const QModelIndex idx = q_ptr->index(m_lInternalModel.size()-1,0,QModelIndex()); const QModelIndex idx = q_ptr->index(m_lInternalModel.size()-1,0,QModelIndex());
emit q_ptr->dataChanged(idx, idx); emit q_ptr->dataChanged(idx, idx);
connect(call, &Call::changed, [this, call]{ slotCallChanged(call); }); connect(call, &Call::changed, this, &CallModelPrivate::slotCallChanged);
connect(call,&Call::stateChanged,this,&CallModelPrivate::slotStateChanged); connect(call,&Call::stateChanged,this,&CallModelPrivate::slotStateChanged);
connect(call,SIGNAL(dtmfPlayed(QString)),this,SLOT(slotDTMFPlayed(QString))); connect(call,SIGNAL(dtmfPlayed(QString)),this,SLOT(slotDTMFPlayed(QString)));
connect(call,&Call::videoStarted,[this,call](Video::Renderer* r) { connect(call,&Call::videoStarted,[this,call](Video::Renderer* r) {
...@@ -593,8 +593,9 @@ void CallModelPrivate::removeInternal(InternalStruct* internal) ...@@ -593,8 +593,9 @@ void CallModelPrivate::removeInternal(InternalStruct* internal)
return; return;
} }
//Using layoutChanged would SEGFAULT when an editor is open
q_ptr->beginRemoveRows(QModelIndex(),idx,idx); q_ptr->beginRemoveRows(QModelIndex(),idx,idx);
//disconnect from all the signal of this call, since it no longer needs to be updated in the model
internal->call_real->disconnect(this);
m_lInternalModel.removeAt(idx); m_lInternalModel.removeAt(idx);
q_ptr->endRemoveRows(); q_ptr->endRemoveRows();
} }
...@@ -770,7 +771,7 @@ Call* CallModelPrivate::addConference(const QString& confID) ...@@ -770,7 +771,7 @@ Call* CallModelPrivate::addConference(const QString& confID)
const QModelIndex idx = q_ptr->index(m_lInternalModel.size()-1,0,QModelIndex()); const QModelIndex idx = q_ptr->index(m_lInternalModel.size()-1,0,QModelIndex());
emit q_ptr->dataChanged(idx, idx); emit q_ptr->dataChanged(idx, idx);
emit q_ptr->layoutChanged(); emit q_ptr->layoutChanged();
connect(newConf, &Call::changed, [this, newConf]{ slotCallChanged(newConf); }); connect(newConf, &Call::changed, this, &CallModelPrivate::slotCallChanged);
connect(newConf,&Call::videoStarted,[this,newConf](Video::Renderer* r) { connect(newConf,&Call::videoStarted,[this,newConf](Video::Renderer* r) {
emit q_ptr->rendererAdded(newConf, r); emit q_ptr->rendererAdded(newConf, r);
}); });
...@@ -1365,47 +1366,46 @@ void CallModelPrivate::slotStateChanged(Call::State newState, Call::State previo ...@@ -1365,47 +1366,46 @@ void CallModelPrivate::slotStateChanged(Call::State newState, Call::State previo
} }
///Update model if the data change ///Update model if the data change
void CallModelPrivate::slotCallChanged(Call* call) void CallModelPrivate::slotCallChanged()
{ {
switch(call->state()) { auto call = qobject_cast<Call*>(sender());
//Transfer is "local" state, it doesn't require the daemon, so it need to be if (!call) return;
//handled "manually" instead of relying on the backend signals
case Call::State::TRANSFERRED: switch(call->state()) {
emit q_ptr->callStateChanged(call, Call::State::TRANSFERRED); //Transfer is "local" state, it doesn't require the daemon, so it need to be
break; //handled "manually" instead of relying on the backend signals
//Same goes for some errors case Call::State::TRANSFERRED:
case Call::State::COUNT__: emit q_ptr->callStateChanged(call, Call::State::TRANSFERRED);
case Call::State::ERROR: break;
removeCall(call); //Same goes for some errors
break; case Call::State::COUNT__:
//Over can be caused by local events case Call::State::ERROR:
case Call::State::ABORTED: removeCall(call);
case Call::State::OVER: break;
removeCall(call); //Over can be caused by local events
break; case Call::State::ABORTED:
//Let the daemon handle the others case Call::State::OVER:
case Call::State::INCOMING: removeCall(call);
case Call::State::RINGING: break;
case Call::State::INITIALIZATION: //Let the daemon handle the others
case Call::State::CONNECTED: case Call::State::INCOMING:
case Call::State::CURRENT: case Call::State::RINGING:
case Call::State::DIALING: case Call::State::INITIALIZATION:
case Call::State::NEW: case Call::State::CONNECTED:
case Call::State::HOLD: case Call::State::CURRENT:
case Call::State::FAILURE: case Call::State::DIALING:
case Call::State::BUSY: case Call::State::NEW:
case Call::State::TRANSF_HOLD: case Call::State::HOLD:
case Call::State::CONFERENCE: case Call::State::FAILURE:
case Call::State::CONFERENCE_HOLD: case Call::State::BUSY:
break; case Call::State::TRANSF_HOLD:
}; case Call::State::CONFERENCE:
case Call::State::CONFERENCE_HOLD:
InternalStruct* callInt = m_shInternalMapping[call]; break;
if (callInt) { };
const QModelIndex idx = q_ptr->getIndex(call);
if (idx.isValid()) const QModelIndex idx = q_ptr->getIndex(call);
emit q_ptr->dataChanged(idx,idx); emit q_ptr->dataChanged(idx,idx);
}
} }
///Add call slot ///Add call slot
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment