From 0d06b1ef9eaa650c4a7bcfecf987fcdc86890111 Mon Sep 17 00:00:00 2001 From: Alexandre Lision <alexandre.lision@savoirfairelinux.com> Date: Wed, 16 Sep 2015 11:09:55 -0400 Subject: [PATCH] call: code cleanup - remove some commented code - remove code redundancy Issue: #75334 Change-Id: Ib103c6688e4f769fc59d0b25820596120efadb28 --- src/call.cpp | 12 +++++------- src/callmodel.cpp | 6 ++---- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/call.cpp b/src/call.cpp index 2cee894e..90046b02 100644 --- a/src/call.cpp +++ b/src/call.cpp @@ -518,12 +518,9 @@ Call* Call::buildHistoryCall(const QMap<QString,QString>& hc) //Try to assiciate a contact now, the real contact object is probably not //loaded yet, but we can get a placeholder for now -// const QString& contactUsed = hc[ Call::HistoryMapFields::CONTACT_USED ]; //TODO - const QString& contactUid = hc[ Call::HistoryMapFields::CONTACT_UID ]; - - + const QString& contactUid = hc[ Call::HistoryMapFields::CONTACT_UID ]; Person* ct = nullptr; - if (!hc[ Call::HistoryMapFields::CONTACT_UID].isEmpty()) + if (!contactUid.isEmpty()) ct = PersonModel::instance()->getPlaceHolder(contactUid.toLatin1()); Account* acc = AccountModel::instance()->getById(accId); @@ -792,7 +789,9 @@ FlagPack<Call::HoldFlags> Call::holdFlags() const ///Generate an human readable string from the difference between StartTimeStamp and StopTimeStamp (or 'now') QString Call::length() const { - if (d_ptr->m_pStartTimeStamp == d_ptr->m_pStopTimeStamp) return QString(); //Invalid + if (d_ptr->m_pStartTimeStamp == d_ptr->m_pStopTimeStamp) + return QString(); //Invalid + int nsec =0; if (d_ptr->m_pStopTimeStamp) nsec = stopTimeStamp() - startTimeStamp();//If the call is over @@ -1552,7 +1551,6 @@ void CallPrivate::cancel() CallManagerInterface & callManager = DBus::CallManager::instance(); qDebug() << "Canceling call. callId : " << q_ptr << "ConfId:" << q_ptr; emit q_ptr->dialNumberChanged(QString()); -// Q_NOREPLY callManager.hangUp(m_DringId); if (!callManager.hangUp(m_DringId)) { qWarning() << "HangUp failed, the call was probably already over"; changeCurrentState(Call::State::OVER); diff --git a/src/callmodel.cpp b/src/callmodel.cpp index 49a0bda5..e23bde52 100644 --- a/src/callmodel.cpp +++ b/src/callmodel.cpp @@ -573,8 +573,8 @@ void CallModelPrivate::removeCall(Call* call, bool noEmit) return; } - if (m_shInternalMapping[call] != nullptr) { - removeInternal(m_shInternalMapping[call]); + if (internal != nullptr) { + removeInternal(internal); //NOTE Do not free the memory, it can still be used elsewhere or in modelindexes } @@ -583,8 +583,6 @@ void CallModelPrivate::removeCall(Call* call, bool noEmit) m_shDringId.remove(m_shDringId.key(internal)); } - removeInternal(internal); - //Restore calls to the main list if they are not really over if (internal->m_lChildren.size()) { foreach(InternalStruct* child,internal->m_lChildren) { -- GitLab