diff --git a/Linphone/core/call/CallList.cpp b/Linphone/core/call/CallList.cpp index 083a19f3a..60ca474f6 100644 --- a/Linphone/core/call/CallList.cpp +++ b/Linphone/core/call/CallList.cpp @@ -159,11 +159,7 @@ CallGui *CallList::getCurrentCall() const { } void CallList::setCurrentCall(CallGui *callGui) { - auto callCore = callGui ? callGui->mCore : nullptr; - if (mCurrentCall != callCore) { - mCurrentCall = callCore; - emit currentCallChanged(); - } + setCurrentCallCore(callGui ? callGui->mCore : nullptr); } void CallList::setCurrentCallCore(QSharedPointer call) { @@ -184,16 +180,12 @@ void CallList::setHaveCall(bool haveCall) { } } -QSharedPointer CallList::getNextCall() const { - QSharedPointer call; +QSharedPointer CallList::getNextCall() { auto currentCall = getCurrentCallCore(); - for (auto it = mList.rbegin(); !call && it != mList.rend(); ++it) { - if (*it != currentCall) { - call = it->objectCast(); - } + for (auto &item : getSharedList()) { + if (item != currentCall) return item; } - - return call; + return nullptr; } void CallList::onStateChanged() { @@ -202,21 +194,26 @@ void CallList::onStateChanged() { case LinphoneEnums::CallState::StreamsRunning: case LinphoneEnums::CallState::Resuming: { auto sharedCall = get(call); - setCurrentCallCore(sharedCall.objectCast()); + setCurrentCallCore(sharedCall ? sharedCall.objectCast() : nullptr); break; } case LinphoneEnums::CallState::Released: { auto sharedCall = get(call); - auto currentCall = getCurrentCallCore(); - // Update current call - if (sharedCall == currentCall) { - // Unpause the next call. The current call will change on resume. - // Assumption: All calls that are not the current are paused. - auto nextCall = getNextCall(); - if (nextCall) nextCall->lSetPaused(false); + if (sharedCall) { + auto currentCall = getCurrentCallCore(); + sharedCall->disconnect(this); + // Update current call + if (currentCall == sharedCall) { + auto nextCall = getNextCall(); + if (nextCall) { + // Unpause the next call. The current call will change on resume. + // Assumption: All calls that are not the current are paused. + nextCall->lSetPaused(false); + } + setCurrentCallCore(nextCall); + } + bool removed = remove(sharedCall); } - sharedCall->disconnect(this); - remove(sharedCall); break; } default: { diff --git a/Linphone/core/call/CallList.hpp b/Linphone/core/call/CallList.hpp index a5c2faec2..02be9408d 100644 --- a/Linphone/core/call/CallList.hpp +++ b/Linphone/core/call/CallList.hpp @@ -45,7 +45,7 @@ public: CallGui *getCurrentCall() const; // Used for Ui QSharedPointer getCurrentCallCore() const; - void setCurrentCall(CallGui* callGui); + void setCurrentCall(CallGui *callGui); void setCurrentCallCore(QSharedPointer call); bool getHaveCall() const; @@ -53,7 +53,7 @@ public: // Get the next call after the current one. Used to switch the current call. // At the moment, it select the last call in the list. - QSharedPointer getNextCall() const; + QSharedPointer getNextCall(); virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; signals: diff --git a/Linphone/model/account/AccountModel.cpp b/Linphone/model/account/AccountModel.cpp index 6c0ee641e..f98056589 100644 --- a/Linphone/model/account/AccountModel.cpp +++ b/Linphone/model/account/AccountModel.cpp @@ -483,8 +483,8 @@ void AccountModel::setPresence(LinphoneEnums::Presence presence, QString presenceNote) { mustBeInLinphoneThread(log().arg(Q_FUNC_INFO)); - lDebug() << log().arg("presence set request to: " + LinphoneEnums::toString(presence) + " user initiated? " + - (userInitiated ? "true" : "false") + " reset to auto? " + (resetToAuto ? "true" : "false")); + lDebug() << log().arg("presence set request to: " + LinphoneEnums::toString(presence) + " | user initiated? " + + (userInitiated ? "true" : "false") + " | reset to auto? " + (resetToAuto ? "true" : "false")); auto core = CoreModel::getInstance()->getCore();